From 6e6ca9710015d1dc8d7049d610ac22c133840b8c Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Mon, 17 Nov 2025 19:20:37 +0100 Subject: [PATCH 1/2] Disable Rubocop Rails/Exit locally This cop makes a lot of sense for the part of the app that runs permanently, but both of these cases are instances where the code being aborted is run as a one-off from the command line. (cherry picked from commit 23417483a8bc87ecba17903e36ccb2c4b7785b54) --- admin/lib/solidus_admin/testing_support/admin_assets.rb | 4 +++- .../solidus/install/app_templates/authentication/existing.rb | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/admin/lib/solidus_admin/testing_support/admin_assets.rb b/admin/lib/solidus_admin/testing_support/admin_assets.rb index b9562ea4648..84251849436 100644 --- a/admin/lib/solidus_admin/testing_support/admin_assets.rb +++ b/admin/lib/solidus_admin/testing_support/admin_assets.rb @@ -3,7 +3,9 @@ RSpec.configure do |config| config.when_first_matching_example_defined(solidus_admin: true) do config.before(:suite) do - system('bin/rails solidus_admin:tailwindcss:build') or abort 'Failed to build Tailwind CSS' + # rubocop:disable Rails/Exit + system("bin/rails solidus_admin:tailwindcss:build") or abort "Failed to build Tailwind CSS" + # rubocop:enable Rails/Exit Rails.application.precompiled_assets end end diff --git a/core/lib/generators/solidus/install/app_templates/authentication/existing.rb b/core/lib/generators/solidus/install/app_templates/authentication/existing.rb index 898254f35d8..41011d823f4 100644 --- a/core/lib/generators/solidus/install/app_templates/authentication/existing.rb +++ b/core/lib/generators/solidus/install/app_templates/authentication/existing.rb @@ -4,7 +4,9 @@ user_class.classify.constantize rescue NameError say_status :error, "Can't find an existing user class named #{user_class.classify}, plese set up one before using this authentication option.", :red + # rubocop:disable Rails/Exit abort + # rubocop:enable Rails/Exit end generate "spree:custom_user #{user_class.shellescape}" From 0f0ad14aaf7c59b943db26d6d1a194fec36559ca Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Mon, 17 Nov 2025 19:23:02 +0100 Subject: [PATCH 2/2] Rubocop: Fix presence cop violations These are fine. (cherry picked from commit b773daaac4072c8de6f00fa4debede351c23725b) --- core/app/models/spree/payment.rb | 2 +- core/app/models/spree/stock_item.rb | 2 +- legacy_promotions/app/models/spree/promotion_handler/cart.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/app/models/spree/payment.rb b/core/app/models/spree/payment.rb index 9f034f60ac7..1c718865649 100644 --- a/core/app/models/spree/payment.rb +++ b/core/app/models/spree/payment.rb @@ -83,7 +83,7 @@ def amount=(amount) when String separator = I18n.t('number.currency.format.separator') number = amount.delete("^0-9-#{separator}\.").tr(separator, '.') - number.to_d if number.present? + number.presence&.to_d end || amount end diff --git a/core/app/models/spree/stock_item.rb b/core/app/models/spree/stock_item.rb index 506cf5aa1fb..8c027bca57f 100644 --- a/core/app/models/spree/stock_item.rb +++ b/core/app/models/spree/stock_item.rb @@ -106,7 +106,7 @@ def conditional_variant_touch def should_touch_variant? # the variant_id changes from nil when a new stock location is added inventory_cache_threshold && - (saved_change_to_count_on_hand&.any? { |cache| cache < inventory_cache_threshold }) || + saved_change_to_count_on_hand&.any? { |cache| cache < inventory_cache_threshold } || saved_change_to_variant_id? end diff --git a/legacy_promotions/app/models/spree/promotion_handler/cart.rb b/legacy_promotions/app/models/spree/promotion_handler/cart.rb index 24360fbd82d..a64b1e82fd8 100644 --- a/legacy_promotions/app/models/spree/promotion_handler/cart.rb +++ b/legacy_promotions/app/models/spree/promotion_handler/cart.rb @@ -61,7 +61,7 @@ def sale_promotions def promotion_code(promotion) order_promotion = order.order_promotions.detect { |op| op.promotion_id == promotion.id } - order_promotion.present? ? order_promotion.promotion_code : nil + order_promotion.presence&.promotion_code end def promotion_includes