Skip to content

Commit

Permalink
Merge pull request #5654 from tvdeyen/4.1-rubocop
Browse files Browse the repository at this point in the history
[4.1] Fix latest rubocop offenses
  • Loading branch information
tvdeyen committed Apr 5, 2024
2 parents 9394f9f + 042193c commit 3537d98
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 9 deletions.
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion api/app/views/spree/api/images/_image.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions backend/app/controllers/spree/admin/products_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion core/app/models/spree/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion core/app/models/spree/promotion_handler/coupon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down
2 changes: 1 addition & 1 deletion core/app/models/spree/stock/splitter/shipping_category.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion core/lib/spree/core/state_machines/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion core/lib/spree/money.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3537d98

Please sign in to comment.