Skip to content

Commit

Permalink
Add and apply Style/ArrayIntersect rubocop rule
Browse files Browse the repository at this point in the history
The `intersect?` method has been added in Ruby 3.1, and it's more
readable than `(a & b).any?`.
  • Loading branch information
javierm committed Sep 7, 2023
1 parent a24ca70 commit e19bb6e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,9 @@ Style/AndOr:
Style/ArrayCoercion:
Enabled: true

Style/ArrayIntersect:
Enabled: true

Style/BlockDelimiters:
Enabled: true

Expand Down
2 changes: 1 addition & 1 deletion app/helpers/translatable_form_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def translations_interface_enabled?
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
Expand Down
2 changes: 1 addition & 1 deletion app/models/sdg/process_enabled.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ def module_name
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

0 comments on commit e19bb6e

Please sign in to comment.