From 038af92b082eaf7206eec70fbc0baa98d0d033e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=AA=E0=A5=8D=E0=A4=B0=E0=A4=A5=E0=A4=AE=E0=A5=87?= =?UTF-8?q?=E0=A4=B6=20Sonpatki?= Date: Tue, 30 Jul 2019 13:49:19 +0530 Subject: [PATCH] Mark ActiveRecord/Aliases as unsafe autocorrect We faced an issue where our custom `update_attributes` method call was changed to `update` but the method name remained same in the method definition. ```ruby def update_attributes end update_attributes ``` ```ruby def update_attributes end update ``` So the cop is not safe for auto correct. --- CHANGELOG.md | 5 +++++ config/default.yml | 1 + manual/cops_rails.md | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 04048e5e01..0aec27826f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ * [#53](https://github.com/rubocop-hq/rubocop-rails/issues/53): Fix a false positive for `Rails/SaveBang` when implicitly return using finder method and creation method connected by `||`. ([@koic][]) +### Changes + +* [#98](https://github.com/rubocop-hq/rubocop-rails/pull/98): Mark `Rails/ActiveRecordAliases` as `SafeAutoCorrect` false and disable autocorrect by default. ([@prathamesh-sonpatki][]) + ## 2.2.1 (2019-07-13) ### Bug fixes @@ -54,3 +58,4 @@ [@fedeagripa]: https://github.com/fedeagripa [@brunvez]: https://github.com/brunvez [@santib]: https://github.com/santib +[@prathamesh-sonpatki]: https://github.com/prathamesh-sonpatki diff --git a/config/default.yml b/config/default.yml index e8ea60d302..4a51a98092 100644 --- a/config/default.yml +++ b/config/default.yml @@ -31,6 +31,7 @@ Rails/ActiveRecordAliases: Use `update!` instead of `update_attributes!`. Enabled: true VersionAdded: '0.53' + SafeAutoCorrect: false Rails/ActiveRecordOverride: Description: >- diff --git a/manual/cops_rails.md b/manual/cops_rails.md index 017184d3c2..b5603e000f 100644 --- a/manual/cops_rails.md +++ b/manual/cops_rails.md @@ -51,7 +51,7 @@ Include | `app/controllers/**/*.rb` | Array Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged --- | --- | --- | --- | --- -Enabled | Yes | Yes | 0.53 | - +Enabled | Yes | Yes (Unsafe) | 0.53 | - Checks that ActiveRecord aliases are not used. The direct method names are more clear and easier to read.