Safely autocorrect Rails/RedirectBackOrTo

Inspecting 1721 files
........................................W...................................................................W................W..W.......W................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................

Offenses:

app/controllers/admin/order_cycles_controller.rb:212:9: W: [Corrected] Rails/RedirectBackOrTo: Use redirect_back_or_to instead of redirect_back with :fallback_location keyword argument.
        redirect_back(fallback_location: root_path)
        ^^^^^^^^^^^^^
app/controllers/locales_controller.rb:6:5: W: [Corrected] Rails/RedirectBackOrTo: Use redirect_back_or_to instead of redirect_back with :fallback_location keyword argument.
    redirect_back fallback_location: main_app.root_url
    ^^^^^^^^^^^^^
app/controllers/spree/admin/invoices_controller.rb:31:9: W: [Corrected] Rails/RedirectBackOrTo: Use redirect_back_or_to instead of redirect_back with :fallback_location keyword argument.
        redirect_back(fallback_location: spree.admin_dashboard_path)
        ^^^^^^^^^^^^^
app/controllers/spree/admin/orders_controller.rb:83:9: W: [Corrected] Rails/RedirectBackOrTo: Use redirect_back_or_to instead of redirect_back with :fallback_location keyword argument.
        redirect_back fallback_location: spree.admin_dashboard_path
        ^^^^^^^^^^^^^
app/controllers/spree/admin/orders_controller.rb:91:25: W: [Corrected] Rails/RedirectBackOrTo: Use redirect_back_or_to instead of redirect_back with :fallback_location keyword argument.
          format.html { redirect_back(fallback_location: spree.admin_dashboard_path) }
                        ^^^^^^^^^^^^^
app/controllers/spree/admin/return_authorizations_controller.rb:13:9: W: [Corrected] Rails/RedirectBackOrTo: Use redirect_back_or_to instead of redirect_back with :fallback_location keyword argument.
        redirect_back fallback_location: spree.admin_dashboard_path
        ^^^^^^^^^^^^^

1721 files inspected, 6 offenses detected, 6 offenses corrected
This commit is contained in:
David Thomas
2026-02-26 15:35:55 -05:00
parent 18869979db
commit 2808a41f0d
6 changed files with 6 additions and 16 deletions

View File

@@ -335,16 +335,6 @@ Rails/OrderArguments:
- 'spec/services/orders/generate_invoice_service_spec.rb'
- 'spec/system/admin/order_cycles/simple_spec.rb'
# Offense count: 6
# This cop supports safe autocorrection (--autocorrect).
Rails/RedirectBackOrTo:
Exclude:
- 'app/controllers/admin/order_cycles_controller.rb'
- 'app/controllers/locales_controller.rb'
- 'app/controllers/spree/admin/invoices_controller.rb'
- 'app/controllers/spree/admin/orders_controller.rb'
- 'app/controllers/spree/admin/return_authorizations_controller.rb'
# Offense count: 1
# Configuration parameters: TransactionMethods.
Rails/TransactionExitStatement:

View File

@@ -209,7 +209,7 @@ module Admin
elsif params[:context] == "checkout_options" && params[:save_and_back_to_list]
redirect_to main_app.admin_order_cycles_path
else
redirect_back(fallback_location: root_path)
redirect_back_or_to(root_path)
end
end

View File

@@ -3,6 +3,6 @@
class LocalesController < BaseController
def show
UserLocaleSetter.new(spree_current_user, params[:id], cookies).set_locale
redirect_back fallback_location: main_app.root_url
redirect_back_or_to(main_app.root_url)
end
end

View File

@@ -28,7 +28,7 @@ module Spree
flash[:error] = t(:must_have_valid_business_number,
enterprise_name: @order.distributor.name)
end
redirect_back(fallback_location: spree.admin_dashboard_path)
redirect_back_or_to(spree.admin_dashboard_path)
end
private

View File

@@ -80,7 +80,7 @@ module Spree
rescue Spree::Core::GatewayError => e
flash[:error] = e.message.to_s
ensure
redirect_back fallback_location: spree.admin_dashboard_path
redirect_back_or_to(spree.admin_dashboard_path)
end
def resend
@@ -88,7 +88,7 @@ module Spree
flash[:success] = t('admin.orders.order_email_resent')
respond_with(@order) do |format|
format.html { redirect_back(fallback_location: spree.admin_dashboard_path) }
format.html { redirect_back_or_to(spree.admin_dashboard_path) }
end
end

View File

@@ -10,7 +10,7 @@ module Spree
def fire
@return_authorization.public_send("#{params[:e]}!")
flash[:success] = Spree.t(:return_authorization_updated)
redirect_back fallback_location: spree.admin_dashboard_path
redirect_back_or_to(spree.admin_dashboard_path)
end
protected