From 4052e555ad17c3891136b6964059717e2efcda20 Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Sat, 27 May 2023 15:04:53 +0900 Subject: [PATCH] Make `Lint/RedundantSafeNavigation` aware of several methods This PR makes `Lint/RedundantSafeNavigation` aware of `blank?`, `presence`, and `present?` methods. --- ...ant_safe_navigation_aware_of_several_methods.md | 1 + config/default.yml | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 changelog/change_make_lint_redundant_safe_navigation_aware_of_several_methods.md diff --git a/changelog/change_make_lint_redundant_safe_navigation_aware_of_several_methods.md b/changelog/change_make_lint_redundant_safe_navigation_aware_of_several_methods.md new file mode 100644 index 0000000000..13e2d0babc --- /dev/null +++ b/changelog/change_make_lint_redundant_safe_navigation_aware_of_several_methods.md @@ -0,0 +1 @@ +* [#1014](https://github.com/rubocop/rubocop-rails/pull/1014): Make `Lint/RedundantSafeNavigation` aware of `blank?`, `presence`, and `present?` methods. ([@koic][]) diff --git a/config/default.yml b/config/default.yml index 1f19e191f6..86eec5d279 100644 --- a/config/default.yml +++ b/config/default.yml @@ -48,6 +48,20 @@ Lint/NumberConversion: - in_milliseconds AllowedPatterns: [] +Lint/RedundantSafeNavigation: + # Add `blank?`, `presence`, and `present?` methods to the default of the RuboCop core. + # https://github.com/rubocop/rubocop/blob/v1.51.0/config/default.yml#L2148-L2159 + AllowedMethods: + - instance_of? + - kind_of? + - is_a? + - eql? + - respond_to? + - equal? + - blank? + - presence + - present? + Rails: Enabled: true DocumentationBaseURL: https://docs.rubocop.org/rubocop-rails