Skip to content

Fix MA0202 false positive for comment-only branches - #1257

Merged
meziantou merged 3 commits into
mainfrom
meziantou-fix-ma0202-false-positive-comment-only-b
Aug 1, 2026
Merged

Fix MA0202 false positive for comment-only branches#1257
meziantou merged 3 commits into
mainfrom
meziantou-fix-ma0202-false-positive-comment-only-b

Conversation

@meziantou

@meziantou meziantou commented Aug 1, 2026

Copy link
Copy Markdown
Owner

MA0202 could report a false positive when conditional compilation branches only contained comments (including XML documentation comments). In that case, tokenization produced an empty signature for each branch, so different comment-only branches were treated as identical.

This change updates branch signature computation to fall back to trimmed raw text when a branch has no tokens, while keeping the existing token-based comparison for branches that contain code. It also adds regression tests for both different and identical XML-comment-only branches, and updates MA0202 documentation to reflect the behavior.

Fixes: #1255
Fixes: #1256

meziantou and others added 3 commits August 1, 2026 02:12
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@meziantou
meziantou enabled auto-merge (squash) August 1, 2026 00:22
@meziantou
meziantou merged commit 5806282 into main Aug 1, 2026
14 checks passed
@meziantou
meziantou deleted the meziantou-fix-ma0202-false-positive-comment-only-b branch August 1, 2026 00:22
This was referenced Aug 1, 2026
This was referenced Aug 6, 2026
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.

Wrong Dictionary unit test for MA0002? MA0202 - false positive on comment

1 participant