autocorrect Style/ArrayIntersect offenses

This commit is contained in:
Carlos Chitty
2025-04-29 14:20:50 -04:00
parent d20ed5c757
commit 17a5b5e620
7 changed files with 6 additions and 18 deletions

View File

@@ -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.

View File

@@ -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?

View File

@@ -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?

View File

@@ -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?

View File

@@ -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

View File

@@ -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

View File

@@ -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