Repository navigation
fix(analyzers): teach regex quantifier heuristics character classes - #156
Merged
Merged
Conversation
…ial properties Roslyn never delivers an attribute attached to a source-generated partial property to a SyntaxKind.Attribute node action, and symbol actions skip the property symbol. Registering on SyntaxKind.CompilationUnit and resolving each descendant attribute through SemanticModel reaches every shape, including the 273 partial properties in pugworks that no rule had ever seen. SupportedDiagnostics now lists all four descriptors, so E128013 and E128014 can report once reached. Version 2.9.7. Co-Authored-By: Claude Code <noreply@anthropic.com>
…xposed Co-Authored-By: Claude Code <noreply@anthropic.com>
GeneratedRegexHelpers marks every index inside a regex character class and skips marked indices in all scans, so a class holding * or + no longer reports E128014 or E128013 on a pattern that cannot backtrack. SupportedDiagnosticsCoverageTests sweeps every analyzer and asserts each static DiagnosticDescriptor field reaches SupportedDiagnostics. The analyzer README install snippet now matches version 2.9.7. Co-Authored-By: Claude
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.
Executive Summary
The 2.9.7
GeneratedRegexAnalyzeraudit left three follow-ups in the roadmap. This PR delivers two of them.E128014 false-positive cause:
GeneratedRegexHelpers.GroupContainsInnerQuantifiercounted*and+inside a character class as quantifiers, so a group holding[-*_]followed by+reported a nested-quantifier warning on a pattern that cannot backtrack. Class contents also broke the paren-matching scans. Fix:BuildCharacterClassMaskmarks every index inside a[...]class in one pass (leading^, leading literal], escapes, unterminated class), and all five scans skip masked indices. No publicRegexParserAPI exists, so a full parse is not available.Descriptor coverage cause: the same audit found descriptors that never reached
SupportedDiagnostics, so rules could not report even when the node was reached. Fix:SupportedDiagnosticsCoverageTestsenumerates all 208 analyzers and asserts the set is non-empty and covers every staticDiagnosticDescriptorfield. Reflection lives in helper methods because E128090 bans it in test methods. The scan covers fields only; a descriptor built inline in a getter would evade it, and none exists today.Release: the branch carries the two unpushed
maincommits (the 2.9.7 version bump and the roadmap audit), so the version-bump gate keeps 2.9.7 and this PR delivers 2.9.7 with both fixes.Code Changes
src/E128.Analyzers/Reliability/GeneratedRegexHelpers.cs: class mask plus class-aware scanstests/E128.Analyzers.Tests/GeneratedRegexE128AnalyzerTests.cs: five class fixturestests/E128.Analyzers.Tests/SupportedDiagnosticsCoverageTests.cs: new sweep testsrc/E128.Analyzers/README.md: install snippet version 2.9.0 to 2.9.7lode/dotnet/analyzers/rule-details-reliability.md,lode/dotnet/analyzers/testing.md,plans/roadmap.md: docsTests and Tooling
scripts/test.sh GeneratedRegexE128AnalyzerTests: 31/31. Sweep: 208/208.scripts/check.sh --all: all green. Full suite: 2889 passed, 0 failed, 2 pre-existing skips.Review Guide
Start with
BuildCharacterClassMaskand the mask checks inGeneratedRegexHelpers, then the sweep test. The fixture names inGeneratedRegexE128AnalyzerTestsmap one to one to each false-positive shape.Rollback
Revert the single squashed commit; the release files and the README revert with it.
Links
plans/roadmap.md, Analyzer Detection and Code Fix section🤖 Generated with Claude Code