From 40580d96c3bcbe0ff6459bc34a61d2c58d6ba3a5 Mon Sep 17 00:00:00 2001 From: Prathamesh Sonpatki Date: Wed, 7 Aug 2019 15:05:39 +0530 Subject: [PATCH] Mark Rails/SaveBang as unsafe autocorrect We faced an issue where our custom `update` method call was changed to `update!` but the method name remained same in the method definition. ```ruby def update end update! ``` ```ruby def update end update ``` So the cop is not safe for auto correct. --- CHANGELOG.md | 3 ++- config/default.yml | 1 + manual/cops_rails.md | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0aec27826f..9234be92f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,8 @@ ### Changes -* [#98](https://github.com/rubocop-hq/rubocop-rails/pull/98): Mark `Rails/ActiveRecordAliases` as `SafeAutoCorrect` false and disable autocorrect by default. ([@prathamesh-sonpatki][]) +* [#98](https://github.com/rubocop-hq/rubocop-rails/pull/98): Mark `Rails/SaveBang` as `SafeAutoCorrect` false and disable autocorrect by default. ([@prathamesh-sonpatki][]) +* [#101](https://github.com/rubocop-hq/rubocop-rails/pull/101): Mark `Rails/SaveBang` as `SafeAutoCorrect` false and disable autocorrect by default. ([@prathamesh-sonpatki][]) ## 2.2.1 (2019-07-13) diff --git a/config/default.yml b/config/default.yml index 4a51a98092..bf9e24d8e0 100644 --- a/config/default.yml +++ b/config/default.yml @@ -404,6 +404,7 @@ Rails/SaveBang: VersionChanged: '0.59' AllowImplicitReturn: true AllowedReceivers: [] + SafeAutoCorrect: false Rails/ScopeArgs: Description: 'Checks the arguments of ActiveRecord scopes.' diff --git a/manual/cops_rails.md b/manual/cops_rails.md index b5603e000f..2915800d1d 100644 --- a/manual/cops_rails.md +++ b/manual/cops_rails.md @@ -2064,7 +2064,7 @@ ConvertTry | `false` | Boolean Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged --- | --- | --- | --- | --- -Disabled | Yes | Yes | 0.42 | 0.59 +Disabled | Yes | Yes (Unsafe) | 0.42 | 0.59 This cop identifies possible cases where Active Record save! or related should be used instead of save because the model might have failed to