Skip to content

Commit 2859349

Browse files
committed
Manually fix linting errors
Using standardrb --fix-unsafely and manualy correct where the fix was not working.
1 parent 5dc47dc commit 2859349

File tree

49 files changed

+177
-175
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+177
-175
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,4 @@ group :release do
8080
end
8181

8282
custom_gemfile = File.expand_path("Gemfile-custom", __dir__)
83-
eval File.read(custom_gemfile), nil, custom_gemfile, 0 if File.exist?(custom_gemfile)
83+
eval File.read(custom_gemfile), nil, custom_gemfile, 0 if File.exist?(custom_gemfile) # rubocop:disable Security/Eval

admin/app/components/solidus_admin/ui/forms/field/component.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def self.text_field(form, method, object: nil, hint: nil, tip: nil, size: :m, **
2727
tag: :input,
2828
size:,
2929
value: object.public_send(method),
30-
error: (errors.to_sentence.capitalize if errors),
30+
error: errors&.to_sentence&.capitalize,
3131
**attributes
3232
}
3333
)
@@ -44,7 +44,7 @@ def self.select(form, method, choices, object: nil, hint: nil, tip: nil, size: :
4444
name: "#{object_name}[#{method}]",
4545
choices:,
4646
value: (object.public_send(method) if object.respond_to?(method)),
47-
error: (errors.to_sentence.capitalize if errors),
47+
error: errors&.to_sentence&.capitalize,
4848
**attributes
4949
)
5050
end
@@ -62,7 +62,7 @@ def self.text_area(form, method, object: nil, hint: nil, tip: nil, size: :m, **a
6262
size:,
6363
tag: :textarea,
6464
value: object.public_send(method),
65-
error: (errors.to_sentence.capitalize if errors),
65+
error: errors&.to_sentence&.capitalize,
6666
**attributes
6767
}
6868
)

admin/app/components/solidus_admin/ui/table/component.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ def initialize(**args)
1919
end
2020

2121
def singular_name
22-
self[:class].model_name.human if self[:class]
22+
self[:class]&.model_name&.human
2323
end
2424

2525
def plural_name
26-
self[:class].model_name.human.pluralize if self[:class]
26+
self[:class]&.model_name&.human&.pluralize
2727
end
2828
end
2929

admin/app/components/solidus_admin/ui/table/ransack_filter/component.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def build(type, value, opt_index = nil)
5353
# @return [Boolean] Returns true if the checkbox should be checked, false otherwise.
5454
def checked?(value)
5555
conditions = params.dig(:q, :g, @index.to_s, :c)
56-
conditions && conditions.values.any? { |c| c[:v]&.include?(value.to_s) }
56+
conditions&.values&.any? { |c| c[:v]&.include?(value.to_s) }
5757
end
5858

5959
SUFFIXES = {

admin/app/controllers/solidus_admin/orders_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def update
4646
load_order
4747

4848
@order.assign_attributes(order_params)
49-
@order.email ||= @order.user.email if @order.user && @order.user.changed?
49+
@order.email ||= @order.user.email if @order&.user&.changed?
5050

5151
if @order.save
5252
flash[:notice] = t(".success")

api/app/controllers/spree/api/addresses_controller.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ def update
1515
authorize! :update, @order, order_token
1616
find_address
1717

18+
@address = @order.send(@order_source)
1819
if @order.update({"#{@order_source}_attributes" => address_params})
19-
@address = @order.send(@order_source)
2020
respond_with(@address, default_template: :show)
2121
else
22-
@address = @order.send(@order_source)
2322
invalid_resource!(@address)
2423
end
2524
end

api/app/controllers/spree/api/inventory_units_controller.rb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def update
1616
inventory_unit.transaction do
1717
if inventory_unit.update(inventory_unit_params)
1818
fire
19-
render :show, status: 200
19+
render :show, status: :ok
2020
else
2121
invalid_resource!(inventory_unit)
2222
end
@@ -30,14 +30,13 @@ def inventory_unit
3030
end
3131

3232
def prepare_event
33-
return unless @event = params[:fire]
33+
@event = params[:fire]
34+
return unless @event
3435

3536
can_event = "can_#{@event}?"
3637

37-
unless inventory_unit.respond_to?(can_event) &&
38-
inventory_unit.send(can_event)
39-
render json: {exception: "cannot transition to #{@event}"},
40-
status: 200
38+
unless inventory_unit.respond_to?(can_event) && inventory_unit.send(can_event)
39+
render json: {exception: "cannot transition to #{@event}"}, status: :ok
4140
false
4241
end
4342
end

api/app/controllers/spree/api/orders_controller.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ def update
9191
end
9292

9393
def current
94-
if current_api_user && @order = current_api_user.last_incomplete_spree_order(store: current_store)
94+
@order = current_api_user.last_incomplete_spree_order(store: current_store)
95+
if current_api_user && @order
9596
respond_with(@order, default_template: :show, locals: {root_object: @order})
9697
else
9798
head :no_content
@@ -122,7 +123,7 @@ def order_params
122123
def prevent_customer_metadata_update
123124
return unless @order&.completed? && cannot?(:admin, Spree::Order)
124125

125-
params[:order].delete(:customer_metadata) if params[:order]
126+
params[:order]&.delete(:customer_metadata)
126127
end
127128

128129
def normalize_params

api/app/controllers/spree/api/products_controller.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ def option_types_params
133133
end
134134

135135
def set_up_shipping_category
136-
if shipping_category = params[:product].delete(:shipping_category)
136+
shipping_category = params[:product].delete(:shipping_category)
137+
if shipping_category
137138
id = Spree::ShippingCategory.find_or_create_by(name: shipping_category).id
138139
params[:product][:shipping_category_id] = id
139140
end

api/lib/spree/api/engine.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ class Engine < Rails::Engine
1010

1111
# Leave initializer empty for backwards-compatibility. Other apps
1212
# might still rely on this event.
13-
initializer "spree.api.environment", before: :load_config_initializers do; end
13+
initializer "spree.api.environment", before: :load_config_initializers do
14+
end
1415

1516
config.after_initialize do
1617
Spree::Api::Config.check_load_defaults_called("Spree::Api::Config")

0 commit comments

Comments
 (0)