Skip to content

Commit 47888bd

Browse files
committed
Controller Helpers: Lint fixes
These are easy enough.
1 parent 43f0720 commit 47888bd

File tree

7 files changed

+10
-33
lines changed

7 files changed

+10
-33
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ Layout/LeadingEmptyLines:
143143
# SupportedStyles: aligned, indented
144144
Layout/MultilineOperationIndentation:
145145
Exclude:
146-
- "core/lib/spree/core/controller_helpers/strong_parameters.rb"
147146
- "core/lib/spree/core/engine.rb"
148147
- "core/lib/spree/core/importer/order.rb"
149148
- "core/lib/spree/permission_sets/default_customer.rb"
@@ -226,12 +225,6 @@ Lint/EmptyConditionalBody:
226225
Exclude:
227226
- "core/lib/spree/preferences/statically_configurable.rb"
228227

229-
# Offense count: 1
230-
# This cop supports safe autocorrection (--autocorrect).
231-
Lint/ParenthesesAsGroupedExpression:
232-
Exclude:
233-
- "core/spec/lib/spree/core/controller_helpers/auth_spec.rb"
234-
235228
# Offense count: 1
236229
# This cop supports safe autocorrection (--autocorrect).
237230
Lint/RedundantCopDisableDirective:
@@ -325,7 +318,6 @@ Rails/Blank:
325318
- "core/app/models/spree/reimbursement_type/exchange.rb"
326319
- "core/app/models/spree/wallet_payment_source.rb"
327320
- "core/app/models/spree/zone.rb"
328-
- "core/lib/spree/core/controller_helpers/auth.rb"
329321
- "core/lib/spree/core/importer/order.rb"
330322
- "core/lib/spree/core/search/base.rb"
331323

@@ -409,12 +401,6 @@ Rails/OutputSafety:
409401
- "core/app/helpers/spree/products_helper.rb"
410402
- "core/app/models/spree/money.rb"
411403

412-
# Offense count: 1
413-
# This cop supports safe autocorrection (--autocorrect).
414-
Rails/Presence:
415-
Exclude:
416-
- "core/lib/spree/core/controller_helpers/common.rb"
417-
418404
# Offense count: 10
419405
# This cop supports safe autocorrection (--autocorrect).
420406
# Configuration parameters: NotNilAndNotEmpty, NotBlank, UnlessBlank.
@@ -471,7 +457,6 @@ Rails/SafeNavigation:
471457
- "core/app/models/spree/variant/pricing_options.rb"
472458
- "core/app/models/spree/wallet.rb"
473459
- "core/app/models/spree/wallet/default_payment_builder.rb"
474-
- "core/spec/lib/spree/core/controller_helpers/order_spec.rb"
475460
- "core/spec/models/spree/variant/vat_price_generator_spec.rb"
476461

477462
# Offense count: 43
@@ -691,7 +676,6 @@ Style/RedundantRegexpEscape:
691676
# Configuration parameters: AllowMultipleReturnValues.
692677
Style/RedundantReturn:
693678
Exclude:
694-
- "core/lib/spree/core/controller_helpers/order.rb"
695679
- "core/lib/spree/preferences/store.rb"
696680

697681
# Offense count: 2
@@ -713,13 +697,6 @@ Style/RedundantSort:
713697
Style/SafeNavigation:
714698
Enabled: false
715699

716-
# Offense count: 2
717-
# This cop supports safe autocorrection (--autocorrect).
718-
# Configuration parameters: AllowModifier.
719-
Style/SoleNestedConditional:
720-
Exclude:
721-
- "core/lib/spree/core/controller_helpers/order.rb"
722-
723700
# Offense count: 13
724701
# This cop supports unsafe autocorrection (--autocorrect-all).
725702
# Configuration parameters: Mode.

core/app/helpers/spree/core/controller_helpers/auth.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def redirect_back_or_default(default)
3636
end
3737

3838
def set_guest_token
39-
unless cookies.signed[:guest_token].present?
39+
if cookies.signed[:guest_token].blank?
4040
cookies.permanent.signed[:guest_token] = Spree::Config[:guest_token_cookie_options].merge(
4141
value: SecureRandom.urlsafe_base64(nil, false),
4242
httponly: true

core/app/helpers/spree/core/controller_helpers/common.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module Common
2424
attr_writer :title
2525

2626
def title
27-
title_string = @title.present? ? @title : accurate_title
27+
title_string = @title.presence || accurate_title
2828
if title_string.present?
2929
if Spree::Config[:always_put_site_name_in_title]
3030
[title_string, default_title].join(' - ')

core/app/helpers/spree/core/controller_helpers/order.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ def current_order(options = {})
3030

3131
if @current_order
3232
@current_order.record_ip_address(ip_address)
33-
return @current_order
33+
@current_order
3434
end
3535
end
3636

3737
def associate_user
3838
@order ||= current_order
39-
if spree_current_user && @order
40-
@order.associate_user!(spree_current_user) if @order.user.blank? || @order.email.blank?
39+
if spree_current_user && @order && (@order.user.blank? || @order.email.blank?)
40+
@order.associate_user!(spree_current_user)
4141
end
4242
end
4343

core/app/helpers/spree/core/controller_helpers/strong_parameters.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ def permitted_checkout_confirm_attributes
4848

4949
def permitted_order_attributes
5050
permitted_checkout_address_attributes +
51-
permitted_checkout_delivery_attributes +
52-
permitted_checkout_payment_attributes +
53-
permitted_checkout_confirm_attributes + [
51+
permitted_checkout_delivery_attributes +
52+
permitted_checkout_payment_attributes +
53+
permitted_checkout_confirm_attributes + [
5454
line_items_attributes: permitted_line_item_attributes
5555
]
5656
end

core/spec/helpers/controller_helpers/auth_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def controller.index
120120
context "when an ancestor defines it" do
121121
it "delegates" do
122122
controller = Class.new(ApplicationController) do
123-
include (Module.new do
123+
include(Module.new do
124124
def spree_current_user
125125
:user
126126
end

core/spec/helpers/controller_helpers/order_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
expect {
4747
subject
4848
}.to change {
49-
Spree::Order.last.try!(:last_ip_address)
49+
Spree::Order.last&.last_ip_address
5050
}.from(nil).to("0.0.0.0")
5151
end
5252
end

0 commit comments

Comments
 (0)