Repository navigation
fix(analyzers): exempt separator-disjoint regex groups and preserve fix language - #159
Merged
Merged
Conversation
…ix language 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
E128014 fired on 21 pre-existing regex sites and blocked a consumer build. A repeated group whose body starts with a mandatory separator, such as
(?:/[^\s:"']+)+, cannot backtrack, so the rule treated a linear pattern as exponential. E128014 now compares the first and last consuming atoms of the group body and stays silent when they cannot match the same text. Unbounded{n,}outer quantifiers now also fire, and bounded{n}/{n,m}repeats stay silent.The two GeneratedRegex code fixes changed what the pattern matches. The nested fix removes the outer quantifier only for a single-atom body; a multi-atom body swaps
+for{1,}and*for{0,}, which keeps the language. The overlapping fix collapses\s+to a bare\sinstead of dropping a required separator. Both fixers now reuse the analyzer detection helpers and the character-class mask, so the rewrite targets the reported element. E128013 messaging now states quadratic backtracking.Code Changes
GeneratedRegexHelpers: newNestedQuantifierSpanresult,FindNestedQuantifierSpan, first/last-atom comparison, unbounded brace quantifier support; mask and overlap helpers made internal for fixer reuse.GeneratedRegexNestedCodeFixProvider/GeneratedRegexOverlappingCodeFixProvider: rewritten on the shared detection, registration skips when the rewrite is a no-op.RegexLiteralFix: addedTryGetPatternso both fixers read the pattern the same way.Tests and Tooling
(?:x+){3,}.{1,}rewrite (diagnostic survives), no-fix on unbounded braces,\s+collapse including the negated-class branch, paren-inside-class.scripts/check.sh --allpassed (shell, format, build, test). Targeted classes: analyzer 35/35, nested fix 6/6, overlapping fix 6/6. Release files and README rule table verified in sync.Review Guide
The heuristic compares atom tokens without expanding character class contents; a class that can match the other atom can exempt a group. This limit is documented in the README and the lode. The multi-atom
{1,}rewrite preserves the language but the diagnostic remains by design.Rollback
Revert the single commit; no data or schema changes.