From e735eb8f188185771c77248d2dee1bba49d81b4a Mon Sep 17 00:00:00 2001 From: Marc-Andre Lafortune Date: Wed, 26 Aug 2020 16:31:46 -0400 Subject: [PATCH 1/2] [Fixes #8321] Enable auto correction for Layout/{Def}EndAlignment, Lint/EmptyEnsure --- CHANGELOG.md | 1 + config/default.yml | 3 --- docs/modules/ROOT/pages/cops_layout.adoc | 8 -------- docs/modules/ROOT/pages/cops_lint.adoc | 10 ---------- spec/rubocop/cli/cli_autocorrect_spec.rb | 4 ++-- 5 files changed, 3 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1527d9308c0..9e3a906b32a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ * [#8158](https://github.com/rubocop-hq/rubocop/issues/8158): Fix `Style/MultilineWhenThen` cop to correctly handle cases with multiline body. ([@dsavochkin][]) * [#7705](https://github.com/rubocop-hq/rubocop/issues/7705): Fix `Style/OneLineConditional` cop to handle if/then/elsif/then/else/end cases. Add `AlwaysCorrectToMultiline` config option to this cop to always convert offenses to the multi-line form (false by default). ([@Lykos][], [@dsavochkin][]) * [#8590](https://github.com/rubocop-hq/rubocop/issues/8590): Fix an error when auto-correcting encoding mismatch file. ([@koic][]) +* [#8321](https://github.com/rubocop-hq/rubocop/issues/8321): Enable auto-correction for `Layout/{Def}EndAlignment`, `Lint/EmptyEnsure`. ([@marcandre][]) ### Changes diff --git a/config/default.yml b/config/default.yml index ab73b084c52..caf08e514fe 100644 --- a/config/default.yml +++ b/config/default.yml @@ -399,7 +399,6 @@ Layout/DefEndAlignment: SupportedStylesAlignWith: - start_of_line - def - AutoCorrect: false Severity: warning Layout/DotPosition: @@ -555,7 +554,6 @@ Layout/EndAlignment: - keyword - variable - start_of_line - AutoCorrect: false Severity: warning Layout/EndOfLine: @@ -1458,7 +1456,6 @@ Lint/EmptyEnsure: Enabled: true VersionAdded: '0.10' VersionChanged: '0.48' - AutoCorrect: false Lint/EmptyExpression: Description: 'Checks for empty expressions.' diff --git a/docs/modules/ROOT/pages/cops_layout.adoc b/docs/modules/ROOT/pages/cops_layout.adoc index 04723d4910b..dda6e8b7582 100644 --- a/docs/modules/ROOT/pages/cops_layout.adoc +++ b/docs/modules/ROOT/pages/cops_layout.adoc @@ -951,10 +951,6 @@ private def foo | `start_of_line` | `start_of_line`, `def` -| AutoCorrect -| `false` -| Boolean - | Severity | `warning` | String @@ -2074,10 +2070,6 @@ variable = | `keyword` | `keyword`, `variable`, `start_of_line` -| AutoCorrect -| `false` -| Boolean - | Severity | `warning` | String diff --git a/docs/modules/ROOT/pages/cops_lint.adoc b/docs/modules/ROOT/pages/cops_lint.adoc index ec1e19d874a..3d1030febdb 100644 --- a/docs/modules/ROOT/pages/cops_lint.adoc +++ b/docs/modules/ROOT/pages/cops_lint.adoc @@ -1063,16 +1063,6 @@ ensure end ---- -=== Configurable attributes - -|=== -| Name | Default value | Configurable values - -| AutoCorrect -| `false` -| Boolean -|=== - == Lint/EmptyExpression |=== diff --git a/spec/rubocop/cli/cli_autocorrect_spec.rb b/spec/rubocop/cli/cli_autocorrect_spec.rb index 88cca7b6572..831114a549b 100644 --- a/spec/rubocop/cli/cli_autocorrect_spec.rb +++ b/spec/rubocop/cli/cli_autocorrect_spec.rb @@ -745,7 +745,7 @@ def func bar rescue StandardError baz - end + end def func x; y; rescue StandardError; z @@ -1111,7 +1111,7 @@ module A module B module A module B - end end + end end RUBY uncorrected = $stdout.string.split($RS).select do |line| line.include?('example.rb:') && !line.include?('[Corrected]') From 4e530f7bf6b8959bc46ce9461a537f6691ebc8be Mon Sep 17 00:00:00 2001 From: Marc-Andre Lafortune Date: Wed, 26 Aug 2020 16:41:22 -0400 Subject: [PATCH 2/2] Enable autocorrection for Style/ClassAndModuleChildren --- CHANGELOG.md | 2 +- config/default.yml | 1 - docs/modules/ROOT/pages/cops_style.adoc | 4 ---- 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e3a906b32a..ac5a043b8bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,7 +29,7 @@ * [#8158](https://github.com/rubocop-hq/rubocop/issues/8158): Fix `Style/MultilineWhenThen` cop to correctly handle cases with multiline body. ([@dsavochkin][]) * [#7705](https://github.com/rubocop-hq/rubocop/issues/7705): Fix `Style/OneLineConditional` cop to handle if/then/elsif/then/else/end cases. Add `AlwaysCorrectToMultiline` config option to this cop to always convert offenses to the multi-line form (false by default). ([@Lykos][], [@dsavochkin][]) * [#8590](https://github.com/rubocop-hq/rubocop/issues/8590): Fix an error when auto-correcting encoding mismatch file. ([@koic][]) -* [#8321](https://github.com/rubocop-hq/rubocop/issues/8321): Enable auto-correction for `Layout/{Def}EndAlignment`, `Lint/EmptyEnsure`. ([@marcandre][]) +* [#8321](https://github.com/rubocop-hq/rubocop/issues/8321): Enable auto-correction for `Layout/{Def}EndAlignment`, `Lint/EmptyEnsure`, `Style/ClassAndModuleChildren`. ([@marcandre][]) ### Changes diff --git a/config/default.yml b/config/default.yml index caf08e514fe..e6b6b1f733a 100644 --- a/config/default.yml +++ b/config/default.yml @@ -2629,7 +2629,6 @@ Style/ClassAndModuleChildren: # have the knowledge to perform either operation safely and thus requires # manual oversight. SafeAutoCorrect: false - AutoCorrect: false Enabled: true VersionAdded: '0.19' # diff --git a/docs/modules/ROOT/pages/cops_style.adoc b/docs/modules/ROOT/pages/cops_style.adoc index c2f3db78c99..cc700e28f7a 100644 --- a/docs/modules/ROOT/pages/cops_style.adoc +++ b/docs/modules/ROOT/pages/cops_style.adoc @@ -980,10 +980,6 @@ end |=== | Name | Default value | Configurable values -| AutoCorrect -| `false` -| Boolean - | EnforcedStyle | `nested` | `nested`, `compact`