diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index d20c350e60..414d0dd5d8 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -479,18 +479,6 @@ Security/Open: Exclude: - 'app/services/image_importer.rb' -# Offense count: 7 -# This cop supports unsafe autocorrection (--autocorrect-all). -Style/ArrayIntersect: - Exclude: - - 'app/models/spree/ability.rb' - - 'app/models/tag_rule/filter_order_cycles.rb' - - 'app/models/tag_rule/filter_payment_methods.rb' - - 'app/models/tag_rule/filter_products.rb' - - 'app/models/tag_rule/filter_shipping_methods.rb' - - 'lib/open_food_network/tag_rule_applicator.rb' - - 'spec/support/matchers/select2_matchers.rb' - # Offense count: 23 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. diff --git a/app/models/tag_rule/filter_order_cycles.rb b/app/models/tag_rule/filter_order_cycles.rb index dd32314e3b..35fd5d9c58 100644 --- a/app/models/tag_rule/filter_order_cycles.rb +++ b/app/models/tag_rule/filter_order_cycles.rb @@ -7,7 +7,7 @@ class TagRule::FilterOrderCycles < TagRule def tags_match?(order_cycle) exchange_tags = exchange_for(order_cycle)&.tag_list || [] preferred_tags = preferred_exchange_tags.split(",") - ( exchange_tags & preferred_tags ).any? + exchange_tags.intersect?(preferred_tags) end def reject_matched? diff --git a/app/models/tag_rule/filter_payment_methods.rb b/app/models/tag_rule/filter_payment_methods.rb index aee60a46fb..bdf35fbff8 100644 --- a/app/models/tag_rule/filter_payment_methods.rb +++ b/app/models/tag_rule/filter_payment_methods.rb @@ -7,7 +7,7 @@ class TagRule::FilterPaymentMethods < TagRule def tags_match?(payment_method) payment_method_tags = payment_method&.tag_list || [] preferred_tags = preferred_payment_method_tags.split(",") - ( payment_method_tags & preferred_tags ).any? + payment_method_tags.intersect?(preferred_tags) end def reject_matched? diff --git a/app/models/tag_rule/filter_products.rb b/app/models/tag_rule/filter_products.rb index fb3908fefa..86095f1c17 100644 --- a/app/models/tag_rule/filter_products.rb +++ b/app/models/tag_rule/filter_products.rb @@ -12,7 +12,7 @@ class TagRule def tags_match?(variant) variant_tags = variant&.[]("tag_list") || [] preferred_tags = preferred_variant_tags.split(",") - (variant_tags & preferred_tags).any? + variant_tags.intersect?(preferred_tags) end def reject_matched? diff --git a/app/models/tag_rule/filter_shipping_methods.rb b/app/models/tag_rule/filter_shipping_methods.rb index e0cdd404c3..ddd28ec46f 100644 --- a/app/models/tag_rule/filter_shipping_methods.rb +++ b/app/models/tag_rule/filter_shipping_methods.rb @@ -11,6 +11,6 @@ class TagRule::FilterShippingMethods < TagRule def tags_match?(shipping_method) shipping_method_tags = shipping_method&.tag_list || [] preferred_tags = preferred_shipping_method_tags.split(",") - ( shipping_method_tags & preferred_tags ).any? + shipping_method_tags.intersect?(preferred_tags) end end diff --git a/lib/open_food_network/tag_rule_applicator.rb b/lib/open_food_network/tag_rule_applicator.rb index d37d485e1d..2bfdf87042 100644 --- a/lib/open_food_network/tag_rule_applicator.rb +++ b/lib/open_food_network/tag_rule_applicator.rb @@ -59,7 +59,7 @@ module OpenFoodNetwork def customer_tags_match?(rule) preferred_tags = rule.preferred_customer_tags.split(",") - (customer_tags & preferred_tags).any? + customer_tags.intersect?(preferred_tags) end end end diff --git a/spec/support/matchers/select2_matchers.rb b/spec/support/matchers/select2_matchers.rb index 93d176958d..8e7be8f87e 100644 --- a/spec/support/matchers/select2_matchers.rb +++ b/spec/support/matchers/select2_matchers.rb @@ -56,7 +56,7 @@ RSpec::Matchers.define :have_select2 do |id, options = {}| # if options.key? :without_options end - if (options.keys & %i(selected options without_options)).any? + if options.keys.intersect?(%i(selected options without_options)) raise "Not yet implemented" end