Skip to content

Commit

Permalink
Controller Helpers: Lint fixes
Browse files Browse the repository at this point in the history
These are easy enough.
  • Loading branch information
mamhoff committed Jan 9, 2025
1 parent a5baa97 commit 38e9282
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 33 deletions.
23 changes: 0 additions & 23 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ Layout/LeadingEmptyLines:
# SupportedStyles: aligned, indented
Layout/MultilineOperationIndentation:
Exclude:
- "core/lib/spree/core/controller_helpers/strong_parameters.rb"
- "core/lib/spree/core/engine.rb"
- "core/lib/spree/core/importer/order.rb"
- "core/lib/spree/permission_sets/default_customer.rb"
Expand Down Expand Up @@ -232,12 +231,6 @@ Lint/EmptyConditionalBody:
Exclude:
- "core/lib/spree/preferences/statically_configurable.rb"

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Lint/ParenthesesAsGroupedExpression:
Exclude:
- "core/spec/lib/spree/core/controller_helpers/auth_spec.rb"

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Lint/RedundantCopDisableDirective:
Expand Down Expand Up @@ -331,7 +324,6 @@ Rails/Blank:
- "core/app/models/spree/reimbursement_type/exchange.rb"
- "core/app/models/spree/wallet_payment_source.rb"
- "core/app/models/spree/zone.rb"
- "core/lib/spree/core/controller_helpers/auth.rb"
- "core/lib/spree/core/importer/order.rb"
- "core/lib/spree/core/search/base.rb"

Expand Down Expand Up @@ -415,12 +407,6 @@ Rails/OutputSafety:
- "core/app/helpers/spree/products_helper.rb"
- "core/lib/spree/money.rb"

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Rails/Presence:
Exclude:
- "core/lib/spree/core/controller_helpers/common.rb"

# Offense count: 10
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: NotNilAndNotEmpty, NotBlank, UnlessBlank.
Expand Down Expand Up @@ -477,7 +463,6 @@ Rails/SafeNavigation:
- "core/app/models/spree/variant/pricing_options.rb"
- "core/app/models/spree/wallet.rb"
- "core/app/models/spree/wallet/default_payment_builder.rb"
- "core/spec/lib/spree/core/controller_helpers/order_spec.rb"
- "core/spec/models/spree/variant/vat_price_generator_spec.rb"

# Offense count: 43
Expand Down Expand Up @@ -698,7 +683,6 @@ Style/RedundantRegexpEscape:
# Configuration parameters: AllowMultipleReturnValues.
Style/RedundantReturn:
Exclude:
- "core/lib/spree/core/controller_helpers/order.rb"
- "core/lib/spree/preferences/store.rb"

# Offense count: 2
Expand All @@ -720,13 +704,6 @@ Style/RedundantSort:
Style/SafeNavigation:
Enabled: false

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowModifier.
Style/SoleNestedConditional:
Exclude:
- "core/lib/spree/core/controller_helpers/order.rb"

# Offense count: 13
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: Mode.
Expand Down
2 changes: 1 addition & 1 deletion core/app/helpers/spree/core/controller_helpers/auth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def redirect_back_or_default(default)
end

def set_guest_token
unless cookies.signed[:guest_token].present?
if cookies.signed[:guest_token].blank?
cookies.permanent.signed[:guest_token] = Spree::Config[:guest_token_cookie_options].merge(
value: SecureRandom.urlsafe_base64(nil, false),
httponly: true
Expand Down
2 changes: 1 addition & 1 deletion core/app/helpers/spree/core/controller_helpers/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module Common
attr_writer :title

def title
title_string = @title.present? ? @title : accurate_title
title_string = @title.presence || accurate_title
if title_string.present?
if Spree::Config[:always_put_site_name_in_title]
[title_string, default_title].join(' - ')
Expand Down
6 changes: 3 additions & 3 deletions core/app/helpers/spree/core/controller_helpers/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ def current_order(options = {})

if @current_order
@current_order.record_ip_address(ip_address)
return @current_order
@current_order
end
end

def associate_user
@order ||= current_order
if spree_current_user && @order
@order.associate_user!(spree_current_user) if @order.user.blank? || @order.email.blank?
if spree_current_user && @order && (@order.user.blank? || @order.email.blank?)
@order.associate_user!(spree_current_user)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ def permitted_checkout_confirm_attributes

def permitted_order_attributes
permitted_checkout_address_attributes +
permitted_checkout_delivery_attributes +
permitted_checkout_payment_attributes +
permitted_checkout_confirm_attributes + [
permitted_checkout_delivery_attributes +
permitted_checkout_payment_attributes +
permitted_checkout_confirm_attributes + [
line_items_attributes: permitted_line_item_attributes
]
end
Expand Down
2 changes: 1 addition & 1 deletion core/spec/helpers/controller_helpers/auth_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def controller.index
context "when an ancestor defines it" do
it "delegates" do
controller = Class.new(ApplicationController) do
include (Module.new do
include(Module.new do
def spree_current_user
:user
end
Expand Down
2 changes: 1 addition & 1 deletion core/spec/helpers/controller_helpers/order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
expect {
subject
}.to change {
Spree::Order.last.try!(:last_ip_address)
Spree::Order.last&.last_ip_address
}.from(nil).to("0.0.0.0")
end
end
Expand Down

0 comments on commit 38e9282

Please sign in to comment.