diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 7ad759f944..1d81f3c8b7 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -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' diff --git a/app/components/confirm_modal_component.rb b/app/components/confirm_modal_component.rb index f1419c579c..ccd0c67797 100644 --- a/app/components/confirm_modal_component.rb +++ b/app/components/confirm_modal_component.rb @@ -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 diff --git a/app/components/help_modal_component.rb b/app/components/help_modal_component.rb index 4af82634c4..297ff34765 100644 --- a/app/components/help_modal_component.rb +++ b/app/components/help_modal_component.rb @@ -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 diff --git a/app/controllers/admin/customers_controller.rb b/app/controllers/admin/customers_controller.rb index 6ae081f37b..9751e9c6bb 100644 --- a/app/controllers/admin/customers_controller.rb +++ b/app/controllers/admin/customers_controller.rb @@ -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 diff --git a/app/controllers/admin/enterprise_fees_controller.rb b/app/controllers/admin/enterprise_fees_controller.rb index 631cd80719..011795c8da 100644 --- a/app/controllers/admin/enterprise_fees_controller.rb +++ b/app/controllers/admin/enterprise_fees_controller.rb @@ -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') diff --git a/app/controllers/admin/enterprise_groups_controller.rb b/app/controllers/admin/enterprise_groups_controller.rb index 65c62ecb93..17a5f32eda 100644 --- a/app/controllers/admin/enterprise_groups_controller.rb +++ b/app/controllers/admin/enterprise_groups_controller.rb @@ -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 diff --git a/app/controllers/admin/enterprises_controller.rb b/app/controllers/admin/enterprises_controller.rb index dbdd701fb8..ff9dcfaea8 100644 --- a/app/controllers/admin/enterprises_controller.rb +++ b/app/controllers/admin/enterprises_controller.rb @@ -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 diff --git a/app/controllers/admin/order_cycles_controller.rb b/app/controllers/admin/order_cycles_controller.rb index 3df12684ff..5eae68c7ce 100644 --- a/app/controllers/admin/order_cycles_controller.rb +++ b/app/controllers/admin/order_cycles_controller.rb @@ -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 diff --git a/app/controllers/admin/reports_controller.rb b/app/controllers/admin/reports_controller.rb index ac3adec7f8..9aff9f597f 100644 --- a/app/controllers/admin/reports_controller.rb +++ b/app/controllers/admin/reports_controller.rb @@ -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 diff --git a/app/controllers/admin/resource_controller.rb b/app/controllers/admin/resource_controller.rb index 753b7d130a..b7764d7d50 100644 --- a/app/controllers/admin/resource_controller.rb +++ b/app/controllers/admin/resource_controller.rb @@ -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| diff --git a/app/controllers/admin/stripe_connect_settings_controller.rb b/app/controllers/admin/stripe_connect_settings_controller.rb index 81181b23c9..54128e6bb0 100644 --- a/app/controllers/admin/stripe_connect_settings_controller.rb +++ b/app/controllers/admin/stripe_connect_settings_controller.rb @@ -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 diff --git a/app/controllers/api/v0/enterprise_attachment_controller.rb b/app/controllers/api/v0/enterprise_attachment_controller.rb index 06555b277b..b46f29b355 100644 --- a/app/controllers/api/v0/enterprise_attachment_controller.rb +++ b/app/controllers/api/v0/enterprise_attachment_controller.rb @@ -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 diff --git a/app/controllers/api/v0/shipments_controller.rb b/app/controllers/api/v0/shipments_controller.rb index f8039097e2..05376a2666 100644 --- a/app/controllers/api/v0/shipments_controller.rb +++ b/app/controllers/api/v0/shipments_controller.rb @@ -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 diff --git a/app/controllers/concerns/extra_fields.rb b/app/controllers/concerns/extra_fields.rb index 058e986a13..b22df1e6ab 100644 --- a/app/controllers/concerns/extra_fields.rb +++ b/app/controllers/concerns/extra_fields.rb @@ -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 diff --git a/app/controllers/concerns/manager_invitations.rb b/app/controllers/concerns/manager_invitations.rb index ea5877aca6..d7b4314282 100644 --- a/app/controllers/concerns/manager_invitations.rb +++ b/app/controllers/concerns/manager_invitations.rb @@ -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 diff --git a/app/controllers/concerns/reports_actions.rb b/app/controllers/concerns/reports_actions.rb index 51cc439b3d..b19d6be9e9 100644 --- a/app/controllers/concerns/reports_actions.rb +++ b/app/controllers/concerns/reports_actions.rb @@ -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? diff --git a/app/controllers/line_items_controller.rb b/app/controllers/line_items_controller.rb index 50173af542..7a0c40e775 100644 --- a/app/controllers/line_items_controller.rb +++ b/app/controllers/line_items_controller.rb @@ -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 diff --git a/app/controllers/payment_gateways/paypal_controller.rb b/app/controllers/payment_gateways/paypal_controller.rb index c4046a250e..b3ba7b9957 100644 --- a/app/controllers/payment_gateways/paypal_controller.rb +++ b/app/controllers/payment_gateways/paypal_controller.rb @@ -50,7 +50,7 @@ module PaymentGateways payer_id: params[:PayerID] ), amount: @order.total, - payment_method: payment_method + payment_method: ) process_payment_completion! diff --git a/app/controllers/spree/admin/mail_methods_controller.rb b/app/controllers/spree/admin/mail_methods_controller.rb index df53f9275b..e3171948a1 100644 --- a/app/controllers/spree/admin/mail_methods_controller.rb +++ b/app/controllers/spree/admin/mail_methods_controller.rb @@ -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 diff --git a/app/controllers/spree/admin/orders/customer_details_controller.rb b/app/controllers/spree/admin/orders/customer_details_controller.rb index cc6d6f679f..7f93651e48 100644 --- a/app/controllers/spree/admin/orders/customer_details_controller.rb +++ b/app/controllers/spree/admin/orders/customer_details_controller.rb @@ -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 diff --git a/app/helpers/admin/injection_helper.rb b/app/helpers/admin/injection_helper.rb index 8211adb1a0..d0ce0e20d1 100644 --- a/app/helpers/admin/injection_helper.rb +++ b/app/helpers/admin/injection_helper.rb @@ -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 diff --git a/app/helpers/checkout_helper.rb b/app/helpers/checkout_helper.rb index c6c2f8d0e7..b9b5ce8d40 100644 --- a/app/helpers/checkout_helper.rb +++ b/app/helpers/checkout_helper.rb @@ -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) diff --git a/app/helpers/injection_helper.rb b/app/helpers/injection_helper.rb index 778f8b7d4b..cb191f1367 100644 --- a/app/helpers/injection_helper.rb +++ b/app/helpers/injection_helper.rb @@ -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 diff --git a/app/helpers/serializer_helper.rb b/app/helpers/serializer_helper.rb index c3134e9c3f..f7e96bf634 100644 --- a/app/helpers/serializer_helper.rb +++ b/app/helpers/serializer_helper.rb @@ -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 diff --git a/app/helpers/spree/admin/base_helper.rb b/app/helpers/spree/admin/base_helper.rb index 31bf441649..9109d082f0 100644 --- a/app/helpers/spree/admin/base_helper.rb +++ b/app/helpers/spree/admin/base_helper.rb @@ -129,7 +129,7 @@ module Spree link_to_with_icon('icon-plus', name, 'javascript:', - data: { target: target }, + data: { target: }, class: css_classes) end