Skip to content

Commit

Permalink
[Fix rubocop#12259] Fix an error for Lint/MixedCaseRange
Browse files Browse the repository at this point in the history
Fixes rubocop#12259.

This PR fixes an error for `Lint/MixedCaseRange`
when using nested character class in regexp.
  • Loading branch information
koic committed Oct 11, 2023
1 parent 986d047 commit e208165
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog/fix_an_error_for_lint_mixed_case_range.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#12259](https://github.com/rubocop/rubocop/issues/12259): Fix an error for `Lint/MixedCaseRange` when using nested character class in regexp. ([@koic][])
2 changes: 1 addition & 1 deletion lib/rubocop/cop/lint/mixed_case_range.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def skip_expression?(expr)

def skip_range?(range_start, range_end)
[range_start, range_end].any? do |bound|
bound.type == :escape
bound.type != :literal
end
end

Expand Down
6 changes: 6 additions & 0 deletions spec/rubocop/cop/lint/mixed_case_range_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,10 @@
foo = /[A\-z]/
RUBY
end

it 'does not register an offense with nested character class' do
expect_no_offenses(<<~RUBY)
foo = /[a-[bc]]/
RUBY
end
end

0 comments on commit e208165

Please sign in to comment.