diff --git a/.rubocop_styleguide.yml b/.rubocop_styleguide.yml index 81d1018a6b9..f2c8f29bb2e 100644 --- a/.rubocop_styleguide.yml +++ b/.rubocop_styleguide.yml @@ -115,6 +115,11 @@ Rails/OutputSafety: Exclude: - spec/**/* +Rails/RedundantActiveRecordAllMethod: + AllowedReceivers: + - ActionMailer::Preview + - ActiveSupport::TimeZone + Rails/SkipsModelValidations: AllowedMethods: - touch diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 7d398188f31..04deca0de99 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -654,17 +654,6 @@ Rails/PluckInWhere: Exclude: - 'app/models/spree/variant.rb' -# Offense count: 4 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: AllowedReceivers. -# AllowedReceivers: ActionMailer::Preview, ActiveSupport::TimeZone -Rails/RedundantActiveRecordAllMethod: - Exclude: - - 'app/models/spree/tax_rate.rb' - - 'app/models/spree/user.rb' - - 'app/models/spree/variant.rb' - - 'spec/system/admin/product_import_spec.rb' - # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). Rails/RelativeDateConstant: diff --git a/app/models/spree/tax_rate.rb b/app/models/spree/tax_rate.rb index af8d82f12d0..868b5e3a9f7 100644 --- a/app/models/spree/tax_rate.rb +++ b/app/models/spree/tax_rate.rb @@ -31,7 +31,7 @@ def self.match(order) return [] if order.distributor && !order.distributor.charges_sales_tax return [] unless order.tax_zone - all.includes(zone: { zone_members: :zoneable }).load.select do |rate| + includes(zone: { zone_members: :zoneable }).load.select do |rate| rate.potentially_applicable?(order.tax_zone) end end diff --git a/app/models/spree/user.rb b/app/models/spree/user.rb index 56c06072628..f7ceb5ddca2 100644 --- a/app/models/spree/user.rb +++ b/app/models/spree/user.rb @@ -96,7 +96,7 @@ def known_users end def build_enterprise_roles - Enterprise.all.find_each do |enterprise| + Enterprise.find_each do |enterprise| unless enterprise_roles.find_by enterprise_id: enterprise.id enterprise_roles.build(enterprise:) end diff --git a/app/models/spree/variant.rb b/app/models/spree/variant.rb index 18b7cb0d244..3b219e646cd 100644 --- a/app/models/spree/variant.rb +++ b/app/models/spree/variant.rb @@ -238,7 +238,7 @@ def set_cost_currency end def create_stock_items - StockLocation.all.find_each do |stock_location| + StockLocation.find_each do |stock_location| stock_location.propagate_variant(self) end end diff --git a/spec/system/admin/product_import_spec.rb b/spec/system/admin/product_import_spec.rb index 21104c4fd5c..baec074a88f 100644 --- a/spec/system/admin/product_import_spec.rb +++ b/spec/system/admin/product_import_spec.rb @@ -51,7 +51,7 @@ count_on_hand: 96) } - let(:shipping_category_id_str) { Spree::ShippingCategory.all.first.id.to_s } + let(:shipping_category_id_str) { Spree::ShippingCategory.first.id.to_s } describe "when importing products from uploaded file" do before do