Skip to content

Commit

Permalink
Mark Rails/SaveBang as unsafe autocorrect
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
prathamesh-sonpatki committed Aug 7, 2019
1 parent 20de97e commit 40580d9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
1 change: 1 addition & 0 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ Rails/SaveBang:
VersionChanged: '0.59'
AllowImplicitReturn: true
AllowedReceivers: []
SafeAutoCorrect: false

Rails/ScopeArgs:
Description: 'Checks the arguments of ActiveRecord scopes.'
Expand Down
2 changes: 1 addition & 1 deletion manual/cops_rails.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 40580d9

Please sign in to comment.