Skip to content
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

Lint/MixedCaseRange error for invalid range #12843

Closed
andyw8 opened this issue Apr 14, 2024 · 0 comments · Fixed by #12844
Closed

Lint/MixedCaseRange error for invalid range #12843

andyw8 opened this issue Apr 14, 2024 · 0 comments · Fixed by #12844
Labels

Comments

@andyw8
Copy link
Contributor

andyw8 commented Apr 14, 2024

As shown below, a regex wouldn't normally be written this way, but it can occur when using an LSP.

Expected behavior

Shouldn't raise.

Actual behavior

undefined method `begin' for nil
/Users/andyw8/.gem/ruby/3.3.0/gems/rubocop-1.62.1/lib/rubocop/cop/lint/mixed_case_range.rb:105:in `rewrite_regexp_range'
/Users/andyw8/.gem/ruby/3.3.0/gems/rubocop-1.62.1/lib/rubocop/cop/lint/mixed_case_range.rb:51:in `block (2 levels) in on_regexp'
/Users/andyw8/.gem/ruby/3.3.0/gems/rubocop-1.62.1/lib/rubocop/cop/base.rb:392:in `correct'
/Users/andyw8/.gem/ruby/3.3.0/gems/rubocop-1.62.1/lib/rubocop/cop/base.rb:181:in `add_offense'
/Users/andyw8/.gem/ruby/3.3.0/gems/rubocop-1.62.1/lib/rubocop/cop/lint/mixed_case_range.rb:50:in `block in on_regexp'
/Users/andyw8/.gem/ruby/3.3.0/gems/rubocop-1.62.1/lib/rubocop/cop/lint/mixed_case_range.rb:65:in `block (2 levels) in each_unsafe_regexp_range'
/Users/andyw8/.gem/ruby/3.3.0/gems/rubocop-1.62.1/lib/rubocop/cop/lint/mixed_case_range.rb:60:in `reject'
/Users/andyw8/.gem/ruby/3.3.0/gems/rubocop-1.62.1/lib/rubocop/cop/lint/mixed_case_range.rb:60:in `block in each_unsafe_regexp_range'
/Users/andyw8/.gem/ruby/3.3.0/gems/regexp_parser-2.9.0/lib/regexp_parser/expression/methods/traverse.rb:75:in `block in each_expression_without_index'

Steps to reproduce the problem

Run against this:

/[A-_]$/

RuboCop version

1.62.1 (using Parser 3.3.0.5, rubocop-ast 1.31.2, running on ruby 3.3.0) [arm64-darwin23]
  - rubocop-minitest 0.35.0
  - rubocop-rake 0.6.0
  - rubocop-sorbet 0.8.0
@koic koic added the bug label Apr 15, 2024
koic added a commit to koic/rubocop that referenced this issue Apr 15, 2024
Fixes rubocop#12843.

This PR fixes an error for `Lint/MixedCaseRange`
When a character between `Z` and `a` is used in the regexp range.
koic added a commit to koic/rubocop that referenced this issue Apr 15, 2024
Fixes rubocop#12843.

This PR fixes an error for `Lint/MixedCaseRange`
when a character between `Z` and `a` is used in the regexp range.
bbatsov pushed a commit that referenced this issue Apr 15, 2024
Fixes #12843.

This PR fixes an error for `Lint/MixedCaseRange`
when a character between `Z` and `a` is used in the regexp range.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants