Skip to content

fix(rules): recognize BOM-prefixed Objective-C source - #1964

Merged
lizhengfeng101 merged 2 commits into
alibaba:mainfrom
Afloat16:fix/objc-bom-sniffing
Nov 22, 2026
Merged

lizhengfeng101 merged 2 commits into
alibaba:mainfrom
Afloat16:fix/objc-bom-sniffing

Conversation

@Afloat16

@Afloat16 Afloat16 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Description

A UTF-8 byte-order mark at the start of an Objective-C .m file becomes part of the first line inspected by the language sniffer. The existing #import, comment, and other Objective-C prefixes no longer match, so the file receives MATLAB review rules. The same problem affects both working-tree reads and reviews at a pinned Git ref.

Remove only an initial UTF-8 BOM before inspecting the first nonblank line. A BOM-only first line can then be skipped normally. Preserve interior U+FEFF characters, the MATLAB fallback, and the existing project/global/custom rule precedence.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Upstream synchronization (2026-11-22)

Merged current main d0744d31b19d9fe97ffeff78dd8fb04e0be69312 in ed23484aa46d0fd78d53c4c41cefb339c6ad3101 (tested tree 62ce003a695ab80e2472b628f27bd70d877ddcc3). The conflict resolution retains the leading-only BOM removal and upstream's strings.SplitSeq iterator. Against current main, the PR still changes only the original sniffer and its regression file.

Validation of this merge tree:

  • make test PACKAGES=./internal/config/rules: passed with the race detector; all 100 top-level rule tests, including the BOM and precedence regressions, passed.
  • make check: passed, including repository-wide license, English-text and Go vet checks.
  • make build: passed.
  • The required ocr review --audience agent --background "..." command was attempted; it could not start because this environment has no configured LLM endpoint. A separate inspection of the complete two-file change and merge-resolution interdiff found no blocking issue.

Go 1.26.10 on Linux. Temporary and cache paths were placed in the workspace because this environment has no /tmp. The earlier coverage result below belongs to the original submission; coverage was not rerun for this synchronization.

Original submission verification

The new regression exercises real repositories through the public resolver in workspace mode, pinned-ref mode, and pinned-ref mode with the shared Git runner. It covers initial BOMs before imports, indentation, comments, and CRLF blank lines, plus MATLAB, Octave, BOM-only, and interior-U+FEFF controls. The working tree is changed after the commit to verify that ref-based resolution actually reads the requested revision. Additional cases preserve project override and merge_system_rule behavior.

The original implementation fails 14 of the 28 subcases; all pass with the fix.

  • make check — passed.
  • make test PACKAGES="./internal/config/rules ./internal/agent ./internal/scan" — passed, including the race detector.
  • make coverage — the complete unit-test suite passed, with 91.7% overall coverage (90% required).
  • make build — passed.

The inherited telemetry sampler was explicitly set to always_on for the test suite. The required ocr review --audience agent --background "..." command was attempted, but could not start because no LLM endpoint is configured in the environment.

Checklist

  • The change follows the project's coding style.
  • Tests cover both workspace and committed content, with rule precedence controls.
  • New and existing unit tests pass locally.
  • I have signed the CLA.

Primary contributor and contribution owner: @Afloat16.

Required tool/model disclosure: OpenAI ChatGPT (GPT-6 Astra Pro).

@CLAassistant

CLAassistant commented Nov 17, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions

Copy link
Copy Markdown
Contributor

✅ OpenCodeReview: Review complete: 0 finding(s) across 1 selected item(s).

@lizhengfeng101

Copy link
Copy Markdown
Contributor

@Afloat16 merge conflict

@lizhengfeng101 lizhengfeng101 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lizhengfeng101
lizhengfeng101 merged commit 9285d1b into alibaba:main Nov 22, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants