Skip to content

Commit

Permalink
Fix rubocop comment directives handling of cops with multiple levels …
Browse files Browse the repository at this point in the history
…in department name
  • Loading branch information
fatkodima committed Oct 22, 2020
1 parent c0ba039 commit 433df69
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -14,6 +14,7 @@
### Bug fixes

* [#8913](https://github.com/rubocop-hq/rubocop/pull/8913): Fix an incorrect auto-correct for `Style/RedundantRegexpCharacterClass` due to quantifier. ([@ysakasin][])
* [#8917](https://github.com/rubocop-hq/rubocop/issues/8917): Fix rubocop comment directives handling of cops with multiple levels in department name. ([@fatkodima][])

## 1.0.0 (2020-10-21)

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/comment_config.rb
Expand Up @@ -8,7 +8,7 @@ class CommentConfig
REDUNDANT_DISABLE = 'Lint/RedundantCopDisableDirective'

# @api private
COP_NAME_PATTERN = '([A-Z]\w+/)?(?:[A-Z]\w+)'
COP_NAME_PATTERN = '([A-Z]\w+/)*(?:[A-Z]\w+)'
# @api private
COP_NAMES_PATTERN = "(?:#{COP_NAME_PATTERN} , )*#{COP_NAME_PATTERN}"
# @api private
Expand Down
11 changes: 10 additions & 1 deletion spec/rubocop/comment_config_spec.rb
Expand Up @@ -56,7 +56,10 @@
'# rubocop:disable RSpec/Example',
'# rubocop:disable Custom2/Number9', # 48
'',
'#=SomeDslDirective # rubocop:disable Layout/LeadingCommentSpace'
'#=SomeDslDirective # rubocop:disable Layout/LeadingCommentSpace',
'# rubocop:disable RSpec/Rails/HttpStatus',
'it { is_expected.to have_http_status 200 }', # 52
'# rubocop:enable RSpec/Rails/HttpStatus'
].join("\n")
end

Expand Down Expand Up @@ -94,6 +97,12 @@ def disabled_lines_of_cop(cop)
end
end

it 'supports disabling cops with multiple levels in department name' do
disabled_lines = disabled_lines_of_cop('RSpec/Rails/HttpStatus')
expected_part = (51..53).to_a
expect(disabled_lines & expected_part).to eq(expected_part)
end

it 'supports enabling/disabling cops without a prefix' do
empty_interpolation_disabled_lines =
disabled_lines_of_cop('Lint/EmptyInterpolation')
Expand Down

0 comments on commit 433df69

Please sign in to comment.