Skip to content

Commit

Permalink
Enable Migration/DepartmentName cop by default
Browse files Browse the repository at this point in the history
This PR enables `Migration/DepartmentName` cop by default.

The cop has been added at #7385.

The cop will promote the migration to adding department name to cop name.
Omitting a department name will not be supported in the future,
so enabling this cop by default will facilitate the migration.

The PR was inspired by the following issue:

> RuboCop no longer supports ambiguous cop names (those without a department).

#7717 (comment)
  • Loading branch information
koic authored and bbatsov committed Feb 17, 2020
1 parent dc1e2e9 commit 75f5b98
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -33,6 +33,7 @@
* Add the method name to highlight area of `Layout/EmptyLineBetweenDefs` to help provide more context. ([@rrosenblum][])
* [#7652](https://github.com/rubocop-hq/rubocop/pull/7652): Allow `pp` to allowed names of `Naming/MethodParameterName` cop in default config. ([@masarakki][])
* [#7309](https://github.com/rubocop-hq/rubocop/pull/7309): Mark `Lint/UselessSetterCall` an "not safe" and improve documentation. ([@jonas054][])
* [#7723](https://github.com/rubocop-hq/rubocop/pull/7723): Enable `Migration/DepartmentName` cop by default. ([@koic][])

## 0.79.0 (2020-01-06)

Expand Down
2 changes: 1 addition & 1 deletion config/default.yml
Expand Up @@ -1887,7 +1887,7 @@ Migration/DepartmentName:
Description: >-
Check that cop names in rubocop:disable (etc) comments are
given with department name.
Enabled: false
Enabled: true

#################### Naming ##############################

Expand Down
2 changes: 1 addition & 1 deletion manual/cops_migration.md
Expand Up @@ -4,7 +4,7 @@

Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
--- | --- | --- | --- | ---
Disabled | Yes | Yes | - | -
Enabled | Yes | Yes | - | -

Check that cop names in rubocop:disable comments are given with
department name.
6 changes: 6 additions & 0 deletions spec/rubocop/cli/cli_auto_gen_config_spec.rb
Expand Up @@ -368,6 +368,12 @@ def f
' Exclude:',
" - 'example1.rb'",
'',
'# Offense count: 2',
'# Cop supports --auto-correct.',
'Migration/DepartmentName:',
' Exclude:',
" - 'example1.rb'",
'',
'# Offense count: 1',
'# Cop supports --auto-correct.',
'# Configuration parameters: EnforcedStyle.',
Expand Down
7 changes: 6 additions & 1 deletion spec/rubocop/cli/cli_options_spec.rb
Expand Up @@ -464,10 +464,11 @@ class SomeCop < Cop
1 Layout/SpaceAroundOperators
1 Layout/Tab
1 Layout/TrailingWhitespace
1 Migration/DepartmentName
1 Style/FrozenStringLiteralComment
1 Style/NumericPredicate
--
6 Total
7 Total
RESULT
end
Expand Down Expand Up @@ -584,6 +585,7 @@ class SomeCop < Cop
expect($stdout.string).to eq(<<~RESULT)
#{file}:1:1: C: Style/FrozenStringLiteralComment: Missing frozen string literal comment.
#{file}:1:8: W: Lint/RedundantCopDisableDirective: Unnecessary disabling of `Style/NumericLiterals`.
#{file}:1:26: C: Migration/DepartmentName: Department name is missing.
#{file}:1:41: C: Layout/TrailingWhitespace: Trailing whitespace detected.
RESULT
end
Expand All @@ -595,6 +597,7 @@ class SomeCop < Cop
expect($stdout.string).to eq(<<~RESULT)
#{file}:1:1: C: Missing frozen string literal comment.
#{file}:1:8: W: Unnecessary disabling of `Style/NumericLiterals`.
#{file}:1:26: C: Department name is missing.
#{file}:1:41: C: Trailing whitespace detected.
RESULT
end
Expand All @@ -614,6 +617,7 @@ class SomeCop < Cop
expect($stdout.string).to eq(<<~RESULT)
#{file}:1:1: C: Style/FrozenStringLiteralComment: Missing frozen string literal comment.
#{file}:1:8: W: Lint/RedundantCopDisableDirective: Unnecessary disabling of `Style/NumericLiterals`.
#{file}:1:26: C: Migration/DepartmentName: Department name is missing.
#{file}:1:41: C: Layout/TrailingWhitespace: Trailing whitespace detected.
RESULT
end
Expand All @@ -624,6 +628,7 @@ class SomeCop < Cop
expect($stdout.string).to eq(<<~RESULT)
#{file}:1:1: C: Missing frozen string literal comment.
#{file}:1:8: W: Unnecessary disabling of `Style/NumericLiterals`.
#{file}:1:26: C: Department name is missing.
#{file}:1:41: C: Trailing whitespace detected.
RESULT
end
Expand Down
2 changes: 2 additions & 0 deletions spec/rubocop/cli_spec.rb
Expand Up @@ -353,7 +353,9 @@ def and_with_args
OUTPUT
expect($stdout.string)
.to eq(<<~RESULT)
#{abs('example.rb')}:3:110: C: Migration/DepartmentName: Department name is missing.
#{abs('example.rb')}:4:81: C: Layout/LineLength: Line is too long. [95/80]
#{abs('example.rb')}:5:28: C: Migration/DepartmentName: Department name is missing.
RESULT
end
end
Expand Down

0 comments on commit 75f5b98

Please sign in to comment.