diff --git a/changelog/change_mark_rails_skips_model_validations_as_unsafe.md b/changelog/change_mark_rails_skips_model_validations_as_unsafe.md new file mode 100644 index 0000000000..c00622911f --- /dev/null +++ b/changelog/change_mark_rails_skips_model_validations_as_unsafe.md @@ -0,0 +1 @@ +* [#1286](https://github.com/rubocop/rubocop-rails/issues/1286): Mark `Rails/SkipsModelValidations` as unsafe. ([@koic][]) diff --git a/config/default.yml b/config/default.yml index da35758392..8956b6f9a1 100644 --- a/config/default.yml +++ b/config/default.yml @@ -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: '<>' ForbiddenMethods: - decrement! - decrement_counter diff --git a/lib/rubocop/cop/rails/skips_model_validations.rb b/lib/rubocop/cop/rails/skips_model_validations.rb index c89cc13422..5a78926c92 100644 --- a/lib/rubocop/cop/rails/skips_model_validations.rb +++ b/lib/rubocop/cop/rails/skips_model_validations.rb @@ -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)