Add and apply Style/ArrayIntersect rubocop rule

The `intersect?` method has been added in Ruby 3.1, and it's more
readable than `(a & b).any?`.
This commit is contained in:
Javi Martín
2023-09-06 12:54:01 +02:00
parent f87d4b589d
commit 584176adfa
3 changed files with 5 additions and 2 deletions

View File

@@ -627,6 +627,9 @@ Style/AndOr:
Style/ArrayCoercion:
Enabled: true
Style/ArrayIntersect:
Enabled: true
Style/BlockDelimiters:
Enabled: true

View File

@@ -8,7 +8,7 @@ module TranslatableFormHelper
end
def backend_translations_enabled?
(controller.class.module_parents & [Admin, Management, Valuation, SDGManagement]).any?
controller.class.module_parents.intersect?([Admin, Management, Valuation, SDGManagement])
end
def highlight_translation_html_class

View File

@@ -43,6 +43,6 @@ class SDG::ProcessEnabled
def relatable?
return true if controller_path_name?
(SDG::Related::RELATABLE_TYPES & [record_or_name.class.name, record_or_name]).any?
SDG::Related::RELATABLE_TYPES.intersect?([record_or_name.class.name, record_or_name])
end
end