Skip to content

Commit 5695986

Browse files
authored
Merge pull request #13972 from dvandersluis/issue/13965た
[Fix #13965] Update `Lint/RedundantCopDisableDirective` to register an offense when cop names are given with improper casing
2 parents 1776749 + 6bd6f89 commit 5695986

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* [#13965](https://github.com/rubocop/rubocop/issues/13965): Update `Lint/RedundantCopDisableDirective` to register an offense when cop names are given with improper casing. ([@dvandersluis][])

lib/rubocop/directive_comment.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class DirectiveComment
1212
# @api private
1313
LINT_SYNTAX_COP = "#{LINT_DEPARTMENT}/Syntax"
1414
# @api private
15-
COP_NAME_PATTERN = '([A-Z]\w+/)*(?:[A-Z]\w+)'
15+
COP_NAME_PATTERN = '([A-Za-z]\w+/)*(?:[A-Za-z]\w+)'
1616
# @api private
1717
COP_NAMES_PATTERN = "(?:#{COP_NAME_PATTERN} , )*#{COP_NAME_PATTERN}"
1818
# @api private

spec/rubocop/cop/lint/redundant_cop_disable_directive_spec.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,28 @@
266266
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #{message}
267267
RUBY
268268
end
269+
270+
context 'when the department starts with a lowercase letter' do
271+
it 'registers an offense' do
272+
expect_offense(<<~RUBY)
273+
# rubocop:disable lint/SelfAssignment
274+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Unnecessary disabling of `lint/SelfAssignment` (did you mean `Lint/SelfAssignment`?).
275+
RUBY
276+
277+
expect_correction('')
278+
end
279+
end
280+
281+
context 'when the cop starts with a lowercase letter' do
282+
it 'registers an offense' do
283+
expect_offense(<<~RUBY)
284+
# rubocop:disable Lint/selfAssignment
285+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Unnecessary disabling of `Lint/selfAssignment` (did you mean `Lint/SelfAssignment`?).
286+
RUBY
287+
288+
expect_correction('')
289+
end
290+
end
269291
end
270292

271293
context 'all cops' do

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy