-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
[Fix #13826] Fix false positives for regex cops when Lint/MixedCaseRange is enabled
#13875
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
koic
merged 1 commit into
rubocop:master
from
Earlopain:remove-regexp-parser-workaround
Feb 20, 2025
Merged
[Fix #13826] Fix false positives for regex cops when Lint/MixedCaseRange is enabled
#13875
koic
merged 1 commit into
rubocop:master
from
Earlopain:remove-regexp-parser-workaround
Feb 20, 2025
Conversation
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
koic
reviewed
Feb 20, 2025
koic
reviewed
Feb 20, 2025
…edCaseRange` is enabled The `RegexpRanges` class was added to work around a bug in regexp_parser with ocals in ranges. But, it destructivly removes all expressions from sets because it doesn't dup them. So, any cop that runs after that wants to look at sets will see nothing at all. Today, the buggy versions are excluded in the gemspec, so the code can simply be removed. I didn't add a new test because the code that would be tested is gone now. It also fixes a false positive for `/[_A-z;&&[^G-f]]/`. This regex only contains a single range, not two.
f9721ce to
91494bf
Compare
Earlopain
added a commit
to Earlopain/rubocop
that referenced
this pull request
Aug 11, 2025
…plicateRegexpCharacterClassElement` is enabled It does `expressions = expressions.to_a`, which does not create a copy. So other cops that run after would not see all the expressions. `.dup` would solve this, but all this does is work around a bug in `regexp_parser` < 2.7.0. RuboCop now requires >= 2.9.3 so all that code can simply be removed. I didn't add a new test because the code that would be tested is gone now. Also see rubocop#13875 for something quite similar.
8 tasks
Earlopain
added a commit
to Earlopain/rubocop
that referenced
this pull request
Aug 11, 2025
…plicateRegexpCharacterClassElement` is enabled It does `expressions = expressions.to_a`, which does not create a copy. So other cops that run after would not see all the expressions. `.dup` would solve this, but all this does is work around a bug in `regexp_parser` < 2.7.0. RuboCop now requires >= 2.9.3 so all that code can simply be removed. I didn't add a new test because the code that would be tested is gone now. Also see rubocop#13875 for something quite similar.
Earlopain
added a commit
to Earlopain/rubocop
that referenced
this pull request
Aug 11, 2025
…plicateRegexpCharacterClassElement` is enabled It does `expressions = expressions.to_a`, which does not create a copy. So other cops that run after would not see all the expressions. `.dup` would solve this, but all this does is work around a bug in `regexp_parser` < 2.7.0. RuboCop now requires >= 2.9.3 so all that code can simply be removed. I didn't add a new test because the code that would be tested is gone now. Also see rubocop#13875 for something quite similar.
Earlopain
added a commit
to Earlopain/rubocop
that referenced
this pull request
Aug 12, 2025
…plicateRegexpCharacterClassElement` is enabled It does `expressions = expressions.to_a`, which does not create a copy. So other cops that run after would not see all the expressions. `.dup` would solve this, but all this does is work around a bug in `regexp_parser` < 2.7.0. RuboCop now requires >= 2.9.3 so all that code can simply be removed. I didn't add a new test because the code that would be tested is gone now. Also see rubocop#13875 for something quite similar.
bbatsov
pushed a commit
that referenced
this pull request
Aug 12, 2025
…RegexpCharacterClassElement` is enabled It does `expressions = expressions.to_a`, which does not create a copy. So other cops that run after would not see all the expressions. `.dup` would solve this, but all this does is work around a bug in `regexp_parser` < 2.7.0. RuboCop now requires >= 2.9.3 so all that code can simply be removed. I didn't add a new test because the code that would be tested is gone now. Also see #13875 for something quite similar.
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.
Fix #13826
The
RegexpRangesclass was added to work around a bug in regexp_parser with ocals in ranges. But, it destructivly removes all expressions from sets because it doesn't dup them. So, any cop that runs after that wants to look at sets will see nothing at all.Today, the buggy versions are excluded in the gemspec, so the code can simply be removed.
I didn't add a new test because the code that would be tested is gone now.
It also fixes a false positive for
/[_A-z;&&[^G-f]]/. This regex only contains a single range, not two.Replace this text with a summary of the changes in your PR.
The more detailed you are, the better.
Before submitting the PR make sure the following are checked:
[Fix #issue-number](if the related issue exists).master(if not - rebase it).bundle exec rake default. It executes all tests and runs RuboCop on its own code.{change_type}_{change_description}.mdif the new code introduces user-observable changes. See changelog entry format for details.