Skip to content

Commit 44747ec

Browse files
committed
[Fix #1286] Mark Rails/SkipsModelValidations as unsafe
Fixes #1286. `Rails/SkipsModelValidations` cop is unsafe if the receiver object is not an Active Record object. So, this PR marks `SkipsModelValidations` as unsafe.
1 parent 6c55cb6 commit 44747ec

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* [#1286](https://github.com/rubocop/rubocop-rails/issues/1286): Mark `Rails/SkipsModelValidations` as unsafe. ([@koic][])

config/default.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1018,8 +1018,9 @@ Rails/SkipsModelValidations:
10181018
See reference for more information.
10191019
Reference: 'https://guides.rubyonrails.org/active_record_validations.html#skipping-validations'
10201020
Enabled: true
1021+
Safe: false
10211022
VersionAdded: '0.47'
1022-
VersionChanged: '2.7'
1023+
VersionChanged: '<<next>>'
10231024
ForbiddenMethods:
10241025
- decrement!
10251026
- decrement_counter

lib/rubocop/cop/rails/skips_model_validations.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ module Rails
99
#
1010
# Methods may be ignored from this rule by configuring a `AllowedMethods`.
1111
#
12+
# @safety
13+
# This cop is unsafe if the receiver object is not an Active Record object.
14+
#
1215
# @example
1316
# # bad
1417
# Article.first.decrement!(:view_count)

0 commit comments

Comments
 (0)