diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 1d81f3c8b7..326b9fe003 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -880,36 +880,6 @@ Style/HashLikeCase: # SupportedShorthandSyntax: always, never, either, consistent Style/HashSyntax: Exclude: - - 'app/helpers/tax_helper.rb' - - 'app/jobs/report_job.rb' - - 'app/jobs/webhook_delivery_job.rb' - - 'app/json_schemas/json_api_schema/structure.rb' - - 'app/mailers/enterprise_mailer.rb' - - 'app/mailers/payment_mailer.rb' - - 'app/mailers/producer_mailer.rb' - - 'app/mailers/spree/order_mailer.rb' - - 'app/mailers/spree/shipment_mailer.rb' - - 'app/mailers/spree/test_mailer.rb' - - 'app/mailers/spree/user_mailer.rb' - - 'app/mailers/subscription_mailer.rb' - - 'app/models/column_preference.rb' - - 'app/models/concerns/calculated_adjustments.rb' - - 'app/models/concerns/order_shipment.rb' - - 'app/models/concerns/variant_stock.rb' - - 'app/models/customer.rb' - - 'app/models/enterprise.rb' - - 'app/models/enterprise_relationship.rb' - - 'app/models/exchange.rb' - - 'app/models/exchange_variant.rb' - - 'app/models/invoice/data_presenter.rb' - - 'app/models/invoice/data_presenter/adjustment.rb' - - 'app/models/invoice/data_presenter/line_item.rb' - - 'app/models/invoice/data_presenter/payment.rb' - - 'app/models/producer_property.rb' - - 'app/models/product_import/entry_validator.rb' - - 'app/models/product_import/product_importer.rb' - - 'app/models/report_blob.rb' - - 'app/models/spree/address.rb' - 'app/models/spree/adjustment.rb' - 'app/models/spree/credit_card.rb' - 'app/models/spree/gateway/pay_pal_express.rb' diff --git a/app/helpers/tax_helper.rb b/app/helpers/tax_helper.rb index 781e9341a3..4b3c61ace8 100644 --- a/app/helpers/tax_helper.rb +++ b/app/helpers/tax_helper.rb @@ -4,7 +4,7 @@ module TaxHelper def display_taxes(taxable, display_zero: true) if !taxable.included_tax_total.zero? amount = Spree::Money.new(taxable.included_tax_total, currency: taxable.currency) - I18n.t(:tax_amount_included, amount: amount) + I18n.t(:tax_amount_included, amount:) elsif !taxable.additional_tax_total.zero? Spree::Money.new(taxable.additional_tax_total, currency: taxable.currency) elsif display_zero diff --git a/app/jobs/report_job.rb b/app/jobs/report_job.rb index 1f7e4d3d7a..73184ae574 100644 --- a/app/jobs/report_job.rb +++ b/app/jobs/report_job.rb @@ -26,7 +26,7 @@ class ReportJob < ApplicationJob def email_result(user, blob) ReportMailer.with( to: user.email, - blob: blob, + blob:, ).report_ready.deliver_later end diff --git a/app/jobs/webhook_delivery_job.rb b/app/jobs/webhook_delivery_job.rb index 7eb0a44b83..6de75361dd 100644 --- a/app/jobs/webhook_delivery_job.rb +++ b/app/jobs/webhook_delivery_job.rb @@ -17,7 +17,7 @@ class WebhookDeliveryJob < ApplicationJob body = { id: job_id, at: Time.zone.now.to_s, - event: event, + event:, data: payload, } diff --git a/app/json_schemas/json_api_schema/structure.rb b/app/json_schemas/json_api_schema/structure.rb index ea72753776..aa2ef42736 100644 --- a/app/json_schemas/json_api_schema/structure.rb +++ b/app/json_schemas/json_api_schema/structure.rb @@ -69,7 +69,7 @@ class JsonApiSchema attributes: { type: :object, properties: attributes, - required: required + required: }, relationships: { type: :object, diff --git a/app/mailers/enterprise_mailer.rb b/app/mailers/enterprise_mailer.rb index fa507cb67a..c64907cf6a 100644 --- a/app/mailers/enterprise_mailer.rb +++ b/app/mailers/enterprise_mailer.rb @@ -12,7 +12,7 @@ class EnterpriseMailer < ApplicationMailer enterprise: @enterprise.name, sitename: Spree::Config[:site_name]) mail(to: enterprise.contact.email, - subject: subject) + subject:) end end @@ -23,7 +23,7 @@ class EnterpriseMailer < ApplicationMailer I18n.with_locale valid_locale(@enterprise.owner) do subject = t('enterprise_mailer.invite_manager.subject', enterprise: @enterprise.name) mail(to: user.email, - subject: subject) + subject:) end end diff --git a/app/mailers/payment_mailer.rb b/app/mailers/payment_mailer.rb index 47eb4ae587..ae38604b98 100644 --- a/app/mailers/payment_mailer.rb +++ b/app/mailers/payment_mailer.rb @@ -8,7 +8,7 @@ class PaymentMailer < ApplicationMailer subject = I18n.t('spree.payment_mailer.authorize_payment.subject', distributor: @payment.order.distributor.name) I18n.with_locale valid_locale(@payment.order.user) do - mail(to: payment.order.email, subject: subject) + mail(to: payment.order.email, subject:) end end @@ -19,7 +19,7 @@ class PaymentMailer < ApplicationMailer order: @payment.order) I18n.with_locale valid_locale(shop_owner) do mail(to: shop_owner.email, - subject: subject) + subject:) end end end diff --git a/app/mailers/producer_mailer.rb b/app/mailers/producer_mailer.rb index b9dd977c78..f4dcb334e7 100644 --- a/app/mailers/producer_mailer.rb +++ b/app/mailers/producer_mailer.rb @@ -14,7 +14,7 @@ class ProducerMailer < ApplicationMailer mail( to: @producer.contact.email, - subject: subject, + subject:, reply_to: @coordinator.contact.email, cc: @coordinator.contact.email ) diff --git a/app/mailers/spree/order_mailer.rb b/app/mailers/spree/order_mailer.rb index 9495566974..1c34a2f326 100644 --- a/app/mailers/spree/order_mailer.rb +++ b/app/mailers/spree/order_mailer.rb @@ -22,7 +22,7 @@ module Spree I18n.with_locale valid_locale(@order.distributor.owner) do subject = I18n.t('spree.order_mailer.cancel_email_for_shop.subject') mail(to: @order.distributor.contact.email, - subject: subject) + subject:) end end @@ -32,7 +32,7 @@ module Spree I18n.with_locale valid_locale(@order.user) do subject = mail_subject(t('spree.order_mailer.confirm_email.subject'), resend) mail(to: @order.email, - subject: subject, + subject:, reply_to: @order.distributor.contact.email) end end @@ -42,7 +42,7 @@ module Spree I18n.with_locale valid_locale(@order.user) do subject = mail_subject(t('spree.order_mailer.confirm_email.subject'), resend) mail(to: @order.distributor.contact.email, - subject: subject) + subject:) end end diff --git a/app/mailers/spree/shipment_mailer.rb b/app/mailers/spree/shipment_mailer.rb index de315dbaac..cbe9bc62e6 100644 --- a/app/mailers/spree/shipment_mailer.rb +++ b/app/mailers/spree/shipment_mailer.rb @@ -6,7 +6,7 @@ module Spree @shipment = shipment.respond_to?(:id) ? shipment : Spree::Shipment.find(shipment) @delivery = delivery subject = base_subject - mail(to: @shipment.order.email, subject: subject) + mail(to: @shipment.order.email, subject:) end private diff --git a/app/mailers/spree/test_mailer.rb b/app/mailers/spree/test_mailer.rb index fb9080b9cb..65ce394ac5 100644 --- a/app/mailers/spree/test_mailer.rb +++ b/app/mailers/spree/test_mailer.rb @@ -5,7 +5,7 @@ module Spree def test_email(user) recipient = user.respond_to?(:id) ? user : Spree::User.find(user) subject = "#{Spree::Config[:site_name]} #{t('spree.test_mailer.test_email.subject')}" - mail(to: recipient.email, subject: subject) + mail(to: recipient.email, subject:) end end end diff --git a/app/mailers/spree/user_mailer.rb b/app/mailers/spree/user_mailer.rb index f1ffbe7d5a..02e24194bc 100644 --- a/app/mailers/spree/user_mailer.rb +++ b/app/mailers/spree/user_mailer.rb @@ -16,7 +16,7 @@ module Spree "#{I18n.t('spree.user_mailer.reset_password_instructions.subject')}" I18n.with_locale valid_locale(user) do - mail(to: user.email, subject: subject) + mail(to: user.email, subject:) end end @@ -39,7 +39,7 @@ module Spree I18n.with_locale valid_locale(@user) do subject = t('spree.user_mailer.confirmation_instructions.subject') mail(to: confirmation_email_address, - subject: subject) + subject:) end end diff --git a/app/mailers/subscription_mailer.rb b/app/mailers/subscription_mailer.rb index 5e7d525f1d..b9aee15045 100644 --- a/app/mailers/subscription_mailer.rb +++ b/app/mailers/subscription_mailer.rb @@ -57,7 +57,7 @@ class SubscriptionMailer < ApplicationMailer confirm_email_subject = t('spree.order_mailer.confirm_email.subject') subject = "#{Spree::Config[:site_name]} #{confirm_email_subject} ##{order.number}" mail(to: order.email, - subject: subject, + subject:, reply_to: order.distributor.contact.email) end end diff --git a/app/models/column_preference.rb b/app/models/column_preference.rb index 3a08aa3a85..3e86f36440 100644 --- a/app/models/column_preference.rb +++ b/app/models/column_preference.rb @@ -17,19 +17,19 @@ class ColumnPreference < ApplicationRecord } } def self.for(user, action_name) - stored_preferences = where(user_id: user.id, action_name: action_name) + stored_preferences = where(user_id: user.id, action_name:) default_preferences = __send__("#{action_name}_columns") filter(default_preferences, user, action_name) default_preferences.each_with_object([]) do |(column_name, default_attributes), preferences| - stored_preference = stored_preferences.find_by(column_name: column_name) + stored_preference = stored_preferences.find_by(column_name:) if stored_preference stored_preference.assign_attributes(default_attributes.select{ |k, _v| stored_preference[k].nil? } ) preferences << stored_preference else - attributes = default_attributes.merge(user_id: user.id, action_name: action_name, - column_name: column_name) + attributes = default_attributes.merge(user_id: user.id, action_name:, + column_name:) preferences << ColumnPreference.new(attributes) end end diff --git a/app/models/concerns/calculated_adjustments.rb b/app/models/concerns/calculated_adjustments.rb index ffee86c178..aa9143a091 100644 --- a/app/models/concerns/calculated_adjustments.rb +++ b/app/models/concerns/calculated_adjustments.rb @@ -45,13 +45,13 @@ module CalculatedAdjustments return if amount.zero? && !mandatory adjustment_attributes = { - amount: amount, + amount:, originator: self, order: order_object_for(adjustable), - label: label, - mandatory: mandatory, - state: state, - tax_category: tax_category + label:, + mandatory:, + state:, + tax_category: } if adjustable.respond_to?(:adjustments) diff --git a/app/models/concerns/order_shipment.rb b/app/models/concerns/order_shipment.rb index 8d1df5dceb..751906d6ae 100644 --- a/app/models/concerns/order_shipment.rb +++ b/app/models/concerns/order_shipment.rb @@ -42,7 +42,7 @@ module OrderShipment shipment = shipments.first - shipping_rate = shipment.shipping_rates.find_by(shipping_method_id: shipping_method_id) + shipping_rate = shipment.shipping_rates.find_by(shipping_method_id:) return unless shipping_rate shipment.selected_shipping_rate_id = shipping_rate.id diff --git a/app/models/concerns/variant_stock.rb b/app/models/concerns/variant_stock.rb index 9ead4fe8b9..f39ab38dc9 100644 --- a/app/models/concerns/variant_stock.rb +++ b/app/models/concerns/variant_stock.rb @@ -122,7 +122,7 @@ module VariantStock # This is the original Spree::StockLocation#move, # except that we raise an error if the stock item is missing, # because, unlike Spree, we should always have exactly one stock item per variant. - stock_item.stock_movements.create!(quantity: quantity, originator: originator) + stock_item.stock_movements.create!(quantity:, originator:) end private diff --git a/app/models/customer.rb b/app/models/customer.rb index 94fe138491..732c15c1ff 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -39,7 +39,7 @@ class Customer < ApplicationRecord scope :of, ->(enterprise) { where(enterprise_id: enterprise) } scope :managed_by, ->(user) { - user&.persisted? ? where(user: user).or(of(Enterprise.managed_by(user))) : none + user&.persisted? ? where(user:).or(of(Enterprise.managed_by(user))) : none } scope :created_manually, -> { where(created_manually: true) } scope :visible, -> { where(id: Spree::Order.complete.select(:customer_id)).or(created_manually) } @@ -61,7 +61,7 @@ class Customer < ApplicationRecord end def associate_user - self.user = user || Spree::User.find_by(email: email) + self.user = user || Spree::User.find_by(email:) end def update_orders_and_delete_canceled_subscriptions diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index 001a287c3e..a7c68b0e4b 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -476,8 +476,8 @@ class Enterprise < ApplicationRecord end def name_is_unique - dups = Enterprise.where(name: name) - dups = dups.where.not(id: id) unless new_record? + dups = Enterprise.where(name:) + dups = dups.where.not(id:) unless new_record? errors.add :name, I18n.t(:enterprise_name_error, email: dups.first.owner.email) if dups.any? end @@ -581,7 +581,7 @@ class Enterprise < ApplicationRecord # We avoid an infinite loop and don't need to touch the whole distributor tree. def touch_distributors Enterprise.distributing_products(supplied_products.select(:id)). - where.not(enterprises: { id: id }). + where.not(enterprises: { id: }). update_all(updated_at: Time.zone.now) end end diff --git a/app/models/enterprise_relationship.rb b/app/models/enterprise_relationship.rb index 2efd7bee3e..3e673eab34 100644 --- a/app/models/enterprise_relationship.rb +++ b/app/models/enterprise_relationship.rb @@ -76,7 +76,7 @@ class EnterpriseRelationship < ApplicationRecord permissions.destroy_all else permissions.where.not(name: perms).destroy_all - perms.map { |name| permissions.find_or_initialize_by name: name } + perms.map { |name| permissions.find_or_initialize_by name: } end end diff --git a/app/models/exchange.rb b/app/models/exchange.rb index f244201398..7e77d3c176 100644 --- a/app/models/exchange.rb +++ b/app/models/exchange.rb @@ -118,7 +118,7 @@ class Exchange < ApplicationRecord return unless variant_ids.any? ExchangeVariant.insert_all( # rubocop:disable Rails/SkipsModelValidations - variant_ids.map{ |variant_id| { variant_id: variant_id, exchange_id: exchange_id } } + variant_ids.map{ |variant_id| { variant_id:, exchange_id: } } ) end @@ -127,7 +127,7 @@ class Exchange < ApplicationRecord ExchangeVariant.where(variant_id: variant_ids). joins(:exchange). - where(exchanges: { order_cycle: order_cycle, incoming: false }). + where(exchanges: { order_cycle:, incoming: false }). delete_all end end diff --git a/app/models/exchange_variant.rb b/app/models/exchange_variant.rb index 094f1a8b50..ed8805be67 100644 --- a/app/models/exchange_variant.rb +++ b/app/models/exchange_variant.rb @@ -11,7 +11,7 @@ class ExchangeVariant < ApplicationRecord def delete_related_outgoing_variants return unless exchange.incoming? - ExchangeVariant.where(variant_id: variant_id). + ExchangeVariant.where(variant_id:). joins(:exchange). where(exchanges: { order_cycle: exchange.order_cycle, incoming: false }). delete_all diff --git a/app/models/invoice/data_presenter.rb b/app/models/invoice/data_presenter.rb index 0245d2dd5b..c4485e9905 100644 --- a/app/models/invoice/data_presenter.rb +++ b/app/models/invoice/data_presenter.rb @@ -116,19 +116,19 @@ class Invoice end def display_outstanding_balance - Spree::Money.new(new_outstanding_balance, currency: currency) + Spree::Money.new(new_outstanding_balance, currency:) end def display_checkout_tax_total - Spree::Money.new(total_tax, currency: currency) + Spree::Money.new(total_tax, currency:) end def display_checkout_total_less_tax - Spree::Money.new(total - total_tax, currency: currency) + Spree::Money.new(total - total_tax, currency:) end def display_total - Spree::Money.new(total, currency: currency) + Spree::Money.new(total, currency:) end end end diff --git a/app/models/invoice/data_presenter/adjustment.rb b/app/models/invoice/data_presenter/adjustment.rb index d1e99ef071..c3dc5c61c2 100644 --- a/app/models/invoice/data_presenter/adjustment.rb +++ b/app/models/invoice/data_presenter/adjustment.rb @@ -10,17 +10,17 @@ class Invoice invoice_update_attributes :label def display_amount - Spree::Money.new(amount, currency: currency) + Spree::Money.new(amount, currency:) end def display_taxes(display_zero: false) if included_tax_total.positive? - amount = Spree::Money.new(included_tax_total, currency: currency) - I18n.t(:tax_amount_included, amount: amount) + amount = Spree::Money.new(included_tax_total, currency:) + I18n.t(:tax_amount_included, amount:) elsif additional_tax_total.positive? - Spree::Money.new(additional_tax_total, currency: currency) + Spree::Money.new(additional_tax_total, currency:) elsif display_zero - Spree::Money.new(0.00, currency: currency) + Spree::Money.new(0.00, currency:) end end end diff --git a/app/models/invoice/data_presenter/line_item.rb b/app/models/invoice/data_presenter/line_item.rb index 869a1f165e..32e5a3e0c8 100644 --- a/app/models/invoice/data_presenter/line_item.rb +++ b/app/models/invoice/data_presenter/line_item.rb @@ -12,20 +12,20 @@ class Invoice delegate :name_to_display, :options_text, to: :variant def display_amount_with_adjustments - Spree::Money.new((price_with_adjustments * quantity), currency: currency) + Spree::Money.new((price_with_adjustments * quantity), currency:) end def single_display_amount_with_adjustments - Spree::Money.new(price_with_adjustments, currency: currency) + Spree::Money.new(price_with_adjustments, currency:) end def display_line_items_taxes(display_zero: true) if included_tax.positive? - Spree::Money.new( included_tax, currency: currency) + Spree::Money.new( included_tax, currency:) elsif added_tax.positive? - Spree::Money.new( added_tax, currency: currency) + Spree::Money.new( added_tax, currency:) elsif display_zero - Spree::Money.new(0.00, currency: currency) + Spree::Money.new(0.00, currency:) end end end diff --git a/app/models/invoice/data_presenter/payment.rb b/app/models/invoice/data_presenter/payment.rb index cbce7dc5cd..bf63fe21d4 100644 --- a/app/models/invoice/data_presenter/payment.rb +++ b/app/models/invoice/data_presenter/payment.rb @@ -14,7 +14,7 @@ class Invoice end def display_amount - Spree::Money.new(amount, currency: currency) + Spree::Money.new(amount, currency:) end def payment_method_name diff --git a/app/models/producer_property.rb b/app/models/producer_property.rb index 4e1e350742..8bb46b6602 100644 --- a/app/models/producer_property.rb +++ b/app/models/producer_property.rb @@ -15,7 +15,7 @@ class ProducerProperty < ApplicationRecord def property_name=(name) return if name.blank? - self.property = Spree::Property.find_by(name: name) || - Spree::Property.create(name: name, presentation: name) + self.property = Spree::Property.find_by(name:) || + Spree::Property.create(name:, presentation: name) end end diff --git a/app/models/product_import/entry_validator.rb b/app/models/product_import/entry_validator.rb index 218863c065..f3dc9783dc 100644 --- a/app/models/product_import/entry_validator.rb +++ b/app/models/product_import/entry_validator.rb @@ -468,12 +468,12 @@ module ProductImport end def mark_as_not_updatable(entry, attribute) - mark_as_invalid(entry, attribute: attribute, + mark_as_invalid(entry, attribute:, error: I18n.t("admin.product_import.model.not_updatable")) end def mark_as_values_must_be_same(entry, attribute) - mark_as_invalid(entry, attribute: attribute, + mark_as_invalid(entry, attribute:, error: I18n.t("admin.product_import.model.values_must_be_same")) end diff --git a/app/models/product_import/product_importer.rb b/app/models/product_import/product_importer.rb index 4f7401cf7d..1967245fb8 100644 --- a/app/models/product_import/product_importer.rb +++ b/app/models/product_import/product_importer.rb @@ -139,7 +139,7 @@ module ProductImport end def import_results - { entries: entries_json, reset_counts: reset_counts } + { entries: entries_json, reset_counts: } end def save_results @@ -151,7 +151,7 @@ module ProductImport inventory_updated: inventory_updated_count, products_reset: products_reset_count, }, - updated_ids: updated_ids, + updated_ids:, errors: errors.full_messages } end @@ -255,9 +255,9 @@ module ProductImport # build_entries and buils_all_entries def add_malformed_csv_error(error_message) unless errors.added?(:importer, I18n.t('admin.product_import.model.malformed_csv', - error_message: error_message)) + error_message:)) errors.add(:importer, I18n.t('admin.product_import.model.malformed_csv', - error_message: error_message)) + error_message:)) end end diff --git a/app/models/report_blob.rb b/app/models/report_blob.rb index 01e99916e0..fb382fba31 100644 --- a/app/models/report_blob.rb +++ b/app/models/report_blob.rb @@ -10,7 +10,7 @@ class ReportBlob < ActiveStorage::Blob # before we know anything about the report file. It enables us to use the # same blob in the controller to read the result. create_before_direct_upload!( - filename: filename, + filename:, byte_size: 0, checksum: "0", content_type: content_type(filename), diff --git a/app/models/spree/address.rb b/app/models/spree/address.rb index 9aa847c861..703babb4ee 100644 --- a/app/models/spree/address.rb +++ b/app/models/spree/address.rb @@ -86,13 +86,13 @@ module Spree def active_merchant_hash { name: full_name, - address1: address1, - address2: address2, - city: city, + address1:, + address2:, + city:, state: state_text, zip: zipcode, country: country.try(:iso), - phone: phone + phone: } end