Skip to content

Conversation

@Earlopain
Copy link
Contributor

@Earlopain Earlopain commented Feb 20, 2025

Fix #13826

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.

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:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.

…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.
@Earlopain Earlopain force-pushed the remove-regexp-parser-workaround branch from f9721ce to 91494bf Compare February 20, 2025 09:28
@koic koic merged commit 8f20191 into rubocop:master Feb 20, 2025
23 checks passed
@Earlopain Earlopain deleted the remove-regexp-parser-workaround branch February 21, 2025 06:16
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 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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enabling Lint/MixedCaseRange causes Style/RedundantRegexpEscape to skip infractions

2 participants