From b47193dead4706af8f312ebee69931dedad00fd7 Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Wed, 13 Oct 2021 19:56:27 +0900 Subject: [PATCH] Mark `Rails/SafeNavigationWithBlank` as unsafe` Follow up to https://github.com/rubocop/rubocop-rails/pull/575#discussion_r726454310. --- .../change_mark_rails_safe_navigation_with_blank_as_unsafe.md | 1 + config/default.yml | 3 ++- docs/modules/ROOT/pages/cops_rails.adoc | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 changelog/change_mark_rails_safe_navigation_with_blank_as_unsafe.md diff --git a/changelog/change_mark_rails_safe_navigation_with_blank_as_unsafe.md b/changelog/change_mark_rails_safe_navigation_with_blank_as_unsafe.md new file mode 100644 index 0000000000..c52fda2cc8 --- /dev/null +++ b/changelog/change_mark_rails_safe_navigation_with_blank_as_unsafe.md @@ -0,0 +1 @@ +* [#577](https://github.com/rubocop/rubocop-rails/pull/577): Mark `Rails/SafeNavigationWithBlank` as unsafe. ([@koic][]) diff --git a/config/default.yml b/config/default.yml index b20840459e..b06b17858d 100644 --- a/config/default.yml +++ b/config/default.yml @@ -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.' diff --git a/docs/modules/ROOT/pages/cops_rails.adoc b/docs/modules/ROOT/pages/cops_rails.adoc index b613fa3a68..6b473f92ab 100644 --- a/docs/modules/ROOT/pages/cops_rails.adoc +++ b/docs/modules/ROOT/pages/cops_rails.adoc @@ -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