diff --git a/.rubocop.yml b/.rubocop.yml index 770b8947b96..b3aa52b0a3f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -128,6 +128,10 @@ Rails/SkipsModelValidations: Exclude: - '*/spec/**/*' +# We have tasks that are not needing the Rails environment for builds and such that are not in the Rails app +Rails/RakeEnvironment: + Enabled: false + # We use a lot of # # expect { diff --git a/api/app/views/spree/api/images/_image.json.jbuilder b/api/app/views/spree/api/images/_image.json.jbuilder index 7045b5bdb38..32385b77c52 100644 --- a/api/app/views/spree/api/images/_image.json.jbuilder +++ b/api/app/views/spree/api/images/_image.json.jbuilder @@ -2,6 +2,6 @@ json.(image, *image_attributes) json.(image, :viewable_type, :viewable_id) -Spree::Image.attachment_definitions[:attachment][:styles].each do |key, _value| +Spree::Image.attachment_definitions[:attachment][:styles].each_key do |key| json.set! "#{key}_url", image.url(key) end diff --git a/backend/app/controllers/spree/admin/payment_methods_controller.rb b/backend/app/controllers/spree/admin/payment_methods_controller.rb index e95bbb3d7bf..2dbfb621803 100644 --- a/backend/app/controllers/spree/admin/payment_methods_controller.rb +++ b/backend/app/controllers/spree/admin/payment_methods_controller.rb @@ -28,7 +28,7 @@ def update invoke_callbacks(:update, :before) attributes = payment_method_params - attributes.each do |key, _value| + attributes.each_key do |key| if key.include?("password") && attributes[key].blank? attributes.delete(key) end diff --git a/backend/app/controllers/spree/admin/products_controller.rb b/backend/app/controllers/spree/admin/products_controller.rb index 519f4fc87b1..b25eb2c30ec 100644 --- a/backend/app/controllers/spree/admin/products_controller.rb +++ b/backend/app/controllers/spree/admin/products_controller.rb @@ -68,7 +68,7 @@ def location_after_save if updating_variant_property_rules? url_params = {} url_params[:ovi] = [] - params[:product][:variant_property_rules_attributes].each do |_index, param_attrs| + params[:product][:variant_property_rules_attributes].each_value do |param_attrs| url_params[:ovi] += param_attrs[:option_value_ids] end spree.admin_product_product_properties_url(@product, url_params) @@ -133,7 +133,7 @@ def render_after_update_error def normalize_variant_property_rules return unless updating_variant_property_rules? - params[:product][:variant_property_rules_attributes].each do |_index, param_attrs| + params[:product][:variant_property_rules_attributes].each_value do |param_attrs| param_attrs[:option_value_ids] = param_attrs[:option_value_ids].split(',') end end diff --git a/core/app/models/spree/order.rb b/core/app/models/spree/order.rb index 781fee27007..aa51dee3f61 100644 --- a/core/app/models/spree/order.rb +++ b/core/app/models/spree/order.rb @@ -630,7 +630,7 @@ def total_applicable_store_credit if can_complete? || complete? valid_store_credit_payments.to_a.sum(&:amount) else - [total, (user.try(:available_store_credit_total, currency: currency) || 0.0)].min + [total, user.try(:available_store_credit_total, currency: currency) || 0.0].min end end diff --git a/core/app/models/spree/promotion_handler/coupon.rb b/core/app/models/spree/promotion_handler/coupon.rb index 9e0e4673404..b5556601f83 100644 --- a/core/app/models/spree/promotion_handler/coupon.rb +++ b/core/app/models/spree/promotion_handler/coupon.rb @@ -73,7 +73,7 @@ def handle_present_promotion(promotion) unless promotion.eligible?(order, promotion_code: promotion_code) set_promotion_eligibility_error_code(promotion) - return (error || ineligible_for_this_order) + return error || ineligible_for_this_order end # If any of the actions for the promotion return `true`, diff --git a/core/app/models/spree/stock/splitter/shipping_category.rb b/core/app/models/spree/stock/splitter/shipping_category.rb index 69ef2d56278..e23efb8b885 100644 --- a/core/app/models/spree/stock/splitter/shipping_category.rb +++ b/core/app/models/spree/stock/splitter/shipping_category.rb @@ -24,7 +24,7 @@ def split_by_category(package) def hash_to_packages(categories) packages = [] - categories.each do |_id, contents| + categories.each_value do |contents| packages << build_package(contents) end packages diff --git a/core/lib/spree/core/state_machines/order.rb b/core/lib/spree/core/state_machines/order.rb index db1faf5e3c5..058419d333f 100644 --- a/core/lib/spree/core/state_machines/order.rb +++ b/core/lib/spree/core/state_machines/order.rb @@ -46,7 +46,11 @@ def define_state_machine! # Persist the state on the order after_transition do |order, transition| - order.state = order.state + # Hard to say if this is really necessary, it was introduced in this commit: + # https://github.com/mamhoff/solidus/commit/fa1d66c42e4c04ee7cd1c20d87e4cdb74a226d3d + # But it seems to be harmless, so we'll keep it for now. + order.state = order.state # rubocop:disable Lint/SelfAssignment + order.state_changes.create( previous_state: transition.from, next_state: transition.to, diff --git a/core/lib/spree/money.rb b/core/lib/spree/money.rb index dc01d2ccb8d..435bc80429f 100644 --- a/core/lib/spree/money.rb +++ b/core/lib/spree/money.rb @@ -35,7 +35,7 @@ def initialize(amount, options = {}) if amount.is_a?(::Money) @money = amount else - currency = (options[:currency] || Spree::Config[:currency]) + currency = options[:currency] || Spree::Config[:currency] @money = Monetize.from_string(amount, currency) end