Skip to content

Commit eca224b

Browse files
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.
1 parent 20de97e commit eca224b

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
### Changes
1414

1515
* [#98](https://github.com/rubocop-hq/rubocop-rails/pull/98): Mark `Rails/ActiveRecordAliases` as `SafeAutoCorrect` false and disable autocorrect by default. ([@prathamesh-sonpatki][])
16+
* [#101](https://github.com/rubocop-hq/rubocop-rails/pull/101): Mark `Rails/SaveBang` as `SafeAutoCorrect` false and disable autocorrect by default. ([@prathamesh-sonpatki][])
1617

1718
## 2.2.1 (2019-07-13)
1819

config/default.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,7 @@ Rails/SaveBang:
404404
VersionChanged: '0.59'
405405
AllowImplicitReturn: true
406406
AllowedReceivers: []
407+
SafeAutoCorrect: false
407408

408409
Rails/ScopeArgs:
409410
Description: 'Checks the arguments of ActiveRecord scopes.'

manual/cops_rails.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2064,7 +2064,7 @@ ConvertTry | `false` | Boolean
20642064

20652065
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
20662066
--- | --- | --- | --- | ---
2067-
Disabled | Yes | Yes | 0.42 | 0.59
2067+
Disabled | Yes | Yes (Unsafe) | 0.42 | 0.59
20682068

20692069
This cop identifies possible cases where Active Record save! or related
20702070
should be used instead of save because the model might have failed to

0 commit comments

Comments
 (0)