Skip to content

Commit 8ac010a

Browse files
authored
Merge pull request #616 from TonyArra/unsafe-redundant-presence
[Fix #615] Change Rails/RedundantPresenceValidationOnBelongsTo to SafeAutoCorrect: false
2 parents 1325bda + 28c2a81 commit 8ac010a

File tree

4 files changed

+8
-1
lines changed

4 files changed

+8
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* [#615](https://github.com/rubocop/rubocop-rails/issues/615): Change `Rails/RedundantPresenceValidationOnBelongsTo` to `SafeAutoCorrect: false`. ([@TonyArra][])

config/default.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,9 @@ Rails/RedundantForeignKey:
627627
Rails/RedundantPresenceValidationOnBelongsTo:
628628
Description: 'Checks for redundant presence validation on belongs_to association.'
629629
Enabled: pending
630+
SafeAutoCorrect: false
630631
VersionAdded: '2.13'
632+
VersionChanged: '<<next>>'
631633

632634
Rails/RedundantReceiverInWithOptions:
633635
Description: 'Checks for redundant receiver in `with_options`.'

docs/modules/ROOT/pages/cops_rails.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3572,7 +3572,7 @@ end
35723572

35733573
| Pending
35743574
| Yes
3575-
| Yes
3575+
| Yes (Unsafe)
35763576
| 2.13
35773577
| -
35783578
|===

lib/rubocop/cop/rails/redundant_presence_validation_on_belongs_to.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ module Rails
88
# explicitly set to `false`. The presence validator is added
99
# automatically, and explicit presence validation is redundant.
1010
#
11+
# @safety
12+
# This cop's autocorrection is unsafe because it changes the default error message
13+
# from "can't be blank" to "must exist".
14+
#
1115
# @example
1216
# # bad
1317
# belongs_to :user

0 commit comments

Comments
 (0)