Skip to content

Commit

Permalink
[Fix rubocop#1286] Mark Rails/SkipsModelValidations as unsafe
Browse files Browse the repository at this point in the history
Fixes rubocop#1286.

`Rails/SkipsModelValidations` cop is unsafe if the receiver object is not an Active Record object.
So, this PR marks `SkipsModelValidations` as unsafe.
  • Loading branch information
koic authored and fwolfst committed Jun 3, 2024
1 parent 5dae970 commit 5e4a809
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#1286](https://github.com/rubocop/rubocop-rails/issues/1286): Mark `Rails/SkipsModelValidations` as unsafe. ([@koic][])
3 changes: 2 additions & 1 deletion config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1018,8 +1018,9 @@ Rails/SkipsModelValidations:
See reference for more information.
Reference: 'https://guides.rubyonrails.org/active_record_validations.html#skipping-validations'
Enabled: true
Safe: false
VersionAdded: '0.47'
VersionChanged: '2.7'
VersionChanged: '<<next>>'
ForbiddenMethods:
- decrement!
- decrement_counter
Expand Down
3 changes: 3 additions & 0 deletions lib/rubocop/cop/rails/skips_model_validations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ module Rails
#
# Methods may be ignored from this rule by configuring a `AllowedMethods`.
#
# @safety
# This cop is unsafe if the receiver object is not an Active Record object.
#
# @example
# # bad
# Article.first.decrement!(:view_count)
Expand Down

0 comments on commit 5e4a809

Please sign in to comment.