test(span-anchor): count #[attr] lines and trailing-comment return types as part of the declaration - #3551
Merged
Conversation
…uct ends CI's samples showed two false positives: PHP 8 attributes (#[\Override]) read as hash comments, and C return-type lines with a trailing comment (`int /* Return 1 on mismatch */`) read as ending in */. Baseline regenerated: php 22.1% -> 21.9%, c 0.1% -> 0%. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YAtpBfGGyBGGovitSVaM5Q
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #3547. This fix was pushed to that branch after it had been squash-merged, so it never reached main.
The first CI run of the span-anchor gate listed sample units, and they showed two false positives in
span_anchor_audit.py's rule:#[\Override]lines were read as#hash comments. So#[\Override] public function groupBy(...)counted as mis-anchored (laravelCollection.php).int /* Return 1 on mismatch, else 0 */on the line abovecob_read_dict(...)was read as ending a construct, because the line ends in*/(gnucobolfileio.c).Fix:
#[is an attribute, never a comment./* … */and// …comments are stripped before the "ends a previous construct" test. That test now looks only at{,},,and;. Pure comment lines are still filler.Baseline regenerated with
span_anchor_audit.py --regenerate: PHP 22.1% → 21.9%, C 0.1% → 0%. Every other language is unchanged: TypeScript 18.1%, JavaScript 0.4%, the rest 0. Both shapes are pinned intest_span_anchor_audit.py.Type of change
CI checklist
pytest tests/tools/test_span_anchor_audit.py: 4 passed, run from/tmpviapython -m pytest.Verification
graph-accuracy-audit.ymlruns on this PR, because it touches the tool and the baseline.🤖 Generated with Claude Code
https://claude.ai/code/session_01YAtpBfGGyBGGovitSVaM5Q
Generated by Claude Code