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 committed May 27, 2024
1 parent 6c55cb6 commit 44747ec
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 44747ec

Please sign in to comment.