diff --git a/CHANGELOG.md b/CHANGELOG.md index 398e9904f07..65d598ed330 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,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) diff --git a/config/default.yml b/config/default.yml index fa1b2bac08c..68a3f289f4d 100644 --- a/config/default.yml +++ b/config/default.yml @@ -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 ############################## diff --git a/manual/cops_migration.md b/manual/cops_migration.md index 6f154cbae5f..bb141d012cf 100644 --- a/manual/cops_migration.md +++ b/manual/cops_migration.md @@ -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. diff --git a/spec/rubocop/cli/cli_auto_gen_config_spec.rb b/spec/rubocop/cli/cli_auto_gen_config_spec.rb index 978db6f6c27..95a4aa82bb9 100644 --- a/spec/rubocop/cli/cli_auto_gen_config_spec.rb +++ b/spec/rubocop/cli/cli_auto_gen_config_spec.rb @@ -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.', diff --git a/spec/rubocop/cli/cli_options_spec.rb b/spec/rubocop/cli/cli_options_spec.rb index 499c52291d9..88be506c50e 100644 --- a/spec/rubocop/cli/cli_options_spec.rb +++ b/spec/rubocop/cli/cli_options_spec.rb @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/spec/rubocop/cli_spec.rb b/spec/rubocop/cli_spec.rb index 807c412b7e3..1719f7ea83f 100644 --- a/spec/rubocop/cli_spec.rb +++ b/spec/rubocop/cli_spec.rb @@ -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