Skip to content

Commit

Permalink
Mark Rails/SafeNavigationWithBlank as unsafe`
Browse files Browse the repository at this point in the history
Follow up to rubocop#575 (comment).
  • Loading branch information
koic committed Oct 13, 2021
1 parent e0b4fce commit b47193d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
@@ -0,0 +1 @@
* [#577](https://github.com/rubocop/rubocop-rails/pull/577): Mark `Rails/SafeNavigationWithBlank` as unsafe. ([@koic][])
3 changes: 2 additions & 1 deletion config/default.yml
Expand Up @@ -709,13 +709,14 @@ Rails/SafeNavigationWithBlank:
Description: 'Avoid `foo&.blank?` in conditionals.'
Enabled: true
VersionAdded: '2.4'
VersionChanged: '2.13'
# While the safe navigation operator is generally a good idea, when
# checking `foo&.blank?` in a conditional, `foo` being `nil` will actually
# do the opposite of what the author intends.
#
# foo&.blank? #=> nil
# foo.blank? #=> true
SafeAutoCorrect: false
Safe: false

Rails/SaveBang:
Description: 'Identifies possible cases where Active Record save! or related should be used.'
Expand Down
4 changes: 2 additions & 2 deletions docs/modules/ROOT/pages/cops_rails.adoc
Expand Up @@ -4197,10 +4197,10 @@ foo&.bar { |e| e.baz }
| Enabled by default | Safe | Supports autocorrection | Version Added | Version Changed

| Enabled
| Yes
| No
| Yes (Unsafe)
| 2.4
| -
| 2.13
|===

This cop checks to make sure safe navigation isn't used with `blank?` in
Expand Down

0 comments on commit b47193d

Please sign in to comment.