From a0a2cb5fcf450e59f5a06b23cc0ab3588c913dd7 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Thu, 8 Feb 2024 11:07:56 +0100 Subject: [PATCH] Fix unsafe rubocop offenses Using rubocop -A and verified they are safe. --- api/app/views/spree/api/images/_image.json.jbuilder | 2 +- .../app/controllers/spree/admin/payment_methods_controller.rb | 2 +- backend/app/controllers/spree/admin/products_controller.rb | 4 ++-- core/app/models/spree/stock/splitter/shipping_category.rb | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) 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/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