Merge pull request #11516 from macanudo527/fix_rubocop_9

Fix Style/HashSyntax 1
This commit is contained in:
Gaetan Craig-Riou
2023-09-12 18:56:47 +10:00
committed by GitHub
25 changed files with 46 additions and 70 deletions

View File

@@ -873,37 +873,13 @@ Style/HashLikeCase:
Exclude:
- 'app/models/enterprise.rb'
# Offense count: 1769
# Offense count: 1715
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
# SupportedShorthandSyntax: always, never, either, consistent
Style/HashSyntax:
Exclude:
- 'app/components/confirm_modal_component.rb'
- 'app/components/help_modal_component.rb'
- 'app/controllers/admin/customers_controller.rb'
- 'app/controllers/admin/enterprise_fees_controller.rb'
- 'app/controllers/admin/enterprise_groups_controller.rb'
- 'app/controllers/admin/enterprises_controller.rb'
- 'app/controllers/admin/order_cycles_controller.rb'
- 'app/controllers/admin/reports_controller.rb'
- 'app/controllers/admin/resource_controller.rb'
- 'app/controllers/admin/stripe_connect_settings_controller.rb'
- 'app/controllers/api/v0/enterprise_attachment_controller.rb'
- 'app/controllers/api/v0/shipments_controller.rb'
- 'app/controllers/concerns/extra_fields.rb'
- 'app/controllers/concerns/manager_invitations.rb'
- 'app/controllers/concerns/reports_actions.rb'
- 'app/controllers/line_items_controller.rb'
- 'app/controllers/payment_gateways/paypal_controller.rb'
- 'app/controllers/spree/admin/mail_methods_controller.rb'
- 'app/controllers/spree/admin/orders/customer_details_controller.rb'
- 'app/helpers/admin/injection_helper.rb'
- 'app/helpers/checkout_helper.rb'
- 'app/helpers/injection_helper.rb'
- 'app/helpers/serializer_helper.rb'
- 'app/helpers/spree/admin/base_helper.rb'
- 'app/helpers/tax_helper.rb'
- 'app/jobs/report_job.rb'
- 'app/jobs/webhook_delivery_job.rb'

View File

@@ -3,7 +3,7 @@
class ConfirmModalComponent < ModalComponent
def initialize(id:, confirm_actions: nil, reflex: nil, controller: nil, message: nil,
confirm_reflexes: nil)
super(id: id, close_button: true)
super(id:, close_button: true)
@confirm_actions = confirm_actions
@reflex = reflex
@confirm_reflexes = confirm_reflexes

View File

@@ -2,6 +2,6 @@
class HelpModalComponent < ModalComponent
def initialize(id:, close_button: true)
super(id: id, close_button: close_button)
super(id:, close_button:)
end
end

View File

@@ -11,7 +11,7 @@ module Admin
respond_override update: { json: {
success: lambda {
tag_rule_mapping = TagRule.mapping_for(Enterprise.where(id: @customer.enterprise))
render_as_json @customer, tag_rule_mapping: tag_rule_mapping
render_as_json @customer, tag_rule_mapping:
},
failure: lambda {
render json: { errors: @customer.errors.full_messages },
@@ -25,7 +25,7 @@ module Admin
format.json do
render json: @collection,
each_serializer: ::Api::Admin::CustomerWithBalanceSerializer,
tag_rule_mapping: tag_rule_mapping,
tag_rule_mapping:,
customer_tags: customer_tags_by_id
end
end
@@ -42,7 +42,7 @@ module Admin
@customer.created_manually = true
if @customer.save
tag_rule_mapping = TagRule.mapping_for(Enterprise.where(id: @customer.enterprise))
render_as_json @customer, tag_rule_mapping: tag_rule_mapping
render_as_json @customer, tag_rule_mapping:
else
render json: { errors: @customer.errors.full_messages }, status: :bad_request
end

View File

@@ -48,7 +48,7 @@ module Admin
private
def load_enterprise_fee_set
@enterprise_fee_set = Sets::EnterpriseFeeSet.new collection: collection
@enterprise_fee_set = Sets::EnterpriseFeeSet.new collection:
end
def load_data
@@ -61,7 +61,7 @@ module Admin
when :for_order_cycle
order_cycle = OrderCycle.find_by(id: params[:order_cycle_id]) if params[:order_cycle_id]
coordinator = Enterprise.find_by(id: params[:coordinator_id]) if params[:coordinator_id]
order_cycle ||= OrderCycle.new(coordinator: coordinator) if coordinator.present?
order_cycle ||= OrderCycle.new(coordinator:) if coordinator.present?
enterprises = OpenFoodNetwork::OrderCyclePermissions.new(spree_current_user,
order_cycle).visible_enterprises
EnterpriseFee.for_enterprises(enterprises).order('enterprise_id', 'fee_type', 'name')

View File

@@ -39,7 +39,7 @@ module Admin
# The ! version is important to raise a RecordNotFound error.
def find_resource
permalink = params[:id] || params[:enterprise_group_id]
EnterpriseGroup.find_by!(permalink: permalink)
EnterpriseGroup.find_by!(permalink:)
end
private

View File

@@ -38,7 +38,7 @@ module Admin
format.html
format.json {
render_as_json @collection, ams_prefix: params[:ams_prefix],
spree_current_user: spree_current_user
spree_current_user:
}
end
end
@@ -72,7 +72,7 @@ module Admin
format.html { redirect_to location_after_save }
format.js { render layout: false }
format.json {
render_as_json @object, ams_prefix: 'index', spree_current_user: spree_current_user
render_as_json @object, ams_prefix: 'index', spree_current_user:
}
end
else
@@ -125,7 +125,7 @@ module Admin
json: @collection,
each_serializer: Api::Admin::ForOrderCycle::EnterpriseSerializer,
order_cycle: @order_cycle,
spree_current_user: spree_current_user
spree_current_user:
)
end
end
@@ -135,7 +135,7 @@ module Admin
respond_to do |format|
format.json do
render_as_json @collection, ams_prefix: params[:ams_prefix] || 'basic',
spree_current_user: spree_current_user
spree_current_user:
end
end
end
@@ -182,7 +182,7 @@ module Admin
when :for_order_cycle
@order_cycle = OrderCycle.find_by(id: params[:order_cycle_id]) if params[:order_cycle_id]
coordinator = Enterprise.find_by(id: params[:coordinator_id]) if params[:coordinator_id]
@order_cycle ||= OrderCycle.new(coordinator: coordinator) if coordinator.present?
@order_cycle ||= OrderCycle.new(coordinator:) if coordinator.present?
enterprises = OpenFoodNetwork::OrderCyclePermissions.new(spree_current_user, @order_cycle)
.visible_enterprises

View File

@@ -189,7 +189,7 @@ module Admin
orders_close_at_gt = raw_params[:q]&.delete(:orders_close_at_gt) || 31.days.ago
raw_params[:q] = {
g: [raw_params.delete(:q) || {}, { m: 'or',
orders_close_at_gt: orders_close_at_gt,
orders_close_at_gt:,
orders_close_at_null: true }]
}
@collection = collection

View File

@@ -83,8 +83,8 @@ module Admin
blob = ReportBlob.create_for_upload_later!(report_filename)
ReportJob.perform_later(
report_class: report_class, user: spree_current_user, params: params,
format: format, blob: blob, channel: ScopedChannel.for_id(params[:uuid]),
report_class:, user: spree_current_user, params:,
format:, blob:, channel: ScopedChannel.for_id(params[:uuid]),
)
head :no_content

View File

@@ -51,7 +51,7 @@ module Admin
def update_positions
params[:positions].each do |id, index|
model_class.where(id: id).update_all(position: index)
model_class.where(id:).update_all(position: index)
end
respond_to do |format|

View File

@@ -21,7 +21,7 @@ module Admin
def update
Spree::Config.set(settings_params.to_h)
resource = t('admin.controllers.stripe_connect_settings.resource')
flash[:success] = t(:successfully_updated, resource: resource)
flash[:success] = t(:successfully_updated, resource:)
redirect_to_edit
end

View File

@@ -21,7 +21,7 @@ module Api
@enterprise.update!(attachment_name => nil)
render json: @enterprise,
serializer: Admin::EnterpriseSerializer,
spree_current_user: spree_current_user
spree_current_user:
end
protected

View File

@@ -110,7 +110,7 @@ module Api
end
def get_or_create_shipment(stock_location_id)
@order.shipment || @order.shipments.create(stock_location_id: stock_location_id)
@order.shipment || @order.shipments.create(stock_location_id:)
end
def shipment_params

View File

@@ -5,11 +5,11 @@ module ExtraFields
extend ActiveSupport::Concern
def invalid_query_param(name, status, msg)
render status: status, json: json_api_error(msg, error_options:
render status:, json: json_api_error(msg, error_options:
{
title: I18n.t("api.query_param.error.title"),
source: { parameter: name },
status: status,
status:,
code: Rack::Utils::SYMBOL_TO_STATUS_CODE[status]
})
end

View File

@@ -5,7 +5,7 @@ module ManagerInvitations
def create_new_manager(email, enterprise)
password = Devise.friendly_token
new_user = Spree::User.create(email: email, unconfirmed_email: email, password: password)
new_user = Spree::User.create(email:, unconfirmed_email: email, password:)
new_user.reset_password_token = Devise.friendly_token
# Same time as used in Devise's lib/devise/models/recoverable.rb.
new_user.reset_password_sent_at = Time.now.utc

View File

@@ -74,8 +74,8 @@ module ReportsActions
def rendering_options
@rendering_options ||= ReportRenderingOptions.where(
user: spree_current_user,
report_type: report_type,
report_subtype: report_subtype
report_type:,
report_subtype:
).first_or_create do |report_rendering_options|
report_rendering_options.options = {
fields_to_show: if request.get?

View File

@@ -31,7 +31,7 @@ class LineItemsController < BaseController
def unauthorized
status = spree_current_user ? 403 : 401
render(body: nil, status: status) && return
render(body: nil, status:) && return
end
def not_found

View File

@@ -50,7 +50,7 @@ module PaymentGateways
payer_id: params[:PayerID]
),
amount: @order.total,
payment_method: payment_method
payment_method:
)
process_payment_completion!

View File

@@ -23,7 +23,7 @@ module Spree
flash[:error] = Spree.t('admin.mail_methods.testmail.delivery_error')
end
rescue StandardError => e
flash[:error] = Spree.t('admin.mail_methods.testmail.error') % { e: e }
flash[:error] = Spree.t('admin.mail_methods.testmail.error') % ({ e: })
ensure
redirect_to spree.edit_admin_mail_methods_url
end

View File

@@ -43,8 +43,8 @@ module Spree
def build_addresses
country_id = Address.default.country.id
@order.build_bill_address(country_id: country_id) if @order.bill_address.nil?
@order.build_ship_address(country_id: country_id) if @order.ship_address.nil?
@order.build_bill_address(country_id:) if @order.bill_address.nil?
@order.build_ship_address(country_id:) if @order.ship_address.nil?
end
def refresh_shipment_rates

View File

@@ -192,16 +192,16 @@ module Admin
json = data.to_json
render partial: "admin/json/injection_ams",
locals: { ngModule: ng_module,
name: name,
json: json }
name:,
json: }
end
def admin_inject_json_ams(ng_module, name, data, serializer, opts = {})
json = serializer.new(data, { scope: spree_current_user }.merge(opts)).to_json
render partial: "admin/json/injection_ams",
locals: { ngModule: ng_module,
name: name,
json: json }
name:,
json: }
end
def admin_inject_json_ams_array(ng_module, name, data, serializer, opts = {})
@@ -210,8 +210,8 @@ module Admin
render partial: "admin/json/injection_ams",
locals: { ngModule: ng_module,
name: name,
json: json }
name:,
json: }
end
end
end

View File

@@ -95,7 +95,7 @@ module CheckoutHelper
"ng-class" => "{error: !fieldValid('#{path}')}"
}.merge args
render "shared/validated_input", name: name, path: path, attributes: attributes
render "shared/validated_input", name:, path:, attributes:
end
def validated_select(name, path, options, args = {})
@@ -106,8 +106,8 @@ module CheckoutHelper
"ng-class" => "{error: !fieldValid('#{path}')}"
}.merge args
render "shared/validated_select", name: name, path: path, options: options,
attributes: attributes
render "shared/validated_select", name:, path:, options:,
attributes:
end
def payment_method_price(method, order)

View File

@@ -80,14 +80,14 @@ module InjectionHelper
inject_json "currentOrder",
current_order,
Api::CurrentOrderSerializer,
current_distributor: current_distributor,
current_order_cycle: current_order_cycle
current_distributor:,
current_order_cycle:
end
def inject_current_order_cycle
serializer = Api::OrderCycleSerializer.new(current_order_cycle)
json = serializer.object.present? ? serializer.to_json : "{}"
render partial: "json/injection_ams", locals: { name: "orderCycleData", json: json }
render partial: "json/injection_ams", locals: { name: "orderCycleData", json: }
end
def inject_taxons
@@ -144,7 +144,7 @@ module InjectionHelper
def inject_json(name, data, serializer, opts = {})
serializer_instance = serializer.new(data, opts)
json = serializer_instance.to_json
render partial: "json/injection_ams", locals: { name: name, json: json }
render partial: "json/injection_ams", locals: { name:, json: }
end
private

View File

@@ -4,7 +4,7 @@ module SerializerHelper
def ids_to_objs(ids)
return [] if ids.blank?
ids.map { |id| { id: id } }
ids.map { |id| { id: } }
end
# Returns an array of the fields a serializer needs from it's object

View File

@@ -129,7 +129,7 @@ module Spree
link_to_with_icon('icon-plus',
name,
'javascript:',
data: { target: target },
data: { target: },
class: css_classes)
end