Autocorrect rubocop offences

This commit is contained in:
Eugene Chaikin 2025-05-28 17:55:32 +02:00 committed by Thomas von Deyen
parent fd07b4515e
commit 620b45d518
16 changed files with 21 additions and 21 deletions

View File

@ -1,4 +1,4 @@
# frozen_string_literal: true
json.attributes(([*line_item_attributes] - [:id]))
json.attributes([*line_item_attributes] - [:id])
json.required_attributes([:variant_id, :quantity])

View File

@ -8,6 +8,6 @@ module Spree
belongs_to :taxon, class_name: "Spree::Taxon", inverse_of: :classifications, touch: true, optional: true
# For https://github.com/spree/spree/issues/3494
validates_uniqueness_of :taxon_id, scope: :product_id, message: :already_linked
validates :taxon_id, uniqueness: { scope: :product_id, message: :already_linked }
end
end

View File

@ -24,7 +24,7 @@ module Spree
raise "The order association has been removed from InventoryUnit. The order is now determined from the shipment."
end
validates_presence_of :shipment, :line_item, :variant
validates :shipment, :line_item, :variant, presence: true
before_destroy :ensure_can_destroy

View File

@ -8,7 +8,7 @@ module Spree
after_create :auto_generate_spree_api_key
validates_uniqueness_of :role_id, scope: :user_id
validates :role_id, uniqueness: { scope: :user_id }
private

View File

@ -22,8 +22,8 @@ module Spree
has_many :shipping_method_stock_locations, dependent: :destroy
has_many :shipping_methods, through: :shipping_method_stock_locations
validates_presence_of :name
validates_uniqueness_of :code, allow_blank: true, case_sensitive: false
validates :name, presence: true
validates :code, uniqueness: { allow_blank: true, case_sensitive: false }
scope :active, -> { where(active: true) }
scope :order_default, -> { order(default: :desc, position: :asc) }

View File

@ -18,9 +18,9 @@ class Spree::StoreCredit < Spree::PaymentSource
belongs_to :credit_type, class_name: 'Spree::StoreCreditType', foreign_key: 'type_id', optional: true
has_many :store_credit_events
validates_presence_of :user_id, :category_id, :type_id, :created_by_id, :currency
validates_numericality_of :amount, { greater_than: 0 }
validates_numericality_of :amount_used, { greater_than_or_equal_to: 0 }
validates :user_id, :category_id, :type_id, :created_by_id, :currency, presence: true
validates :amount, numericality: { greater_than: 0 }
validates :amount_used, numericality: { greater_than_or_equal_to: 0 }
validate :amount_used_less_than_or_equal_to_amount
validate :amount_authorized_less_than_or_equal_to_amount

View File

@ -9,7 +9,7 @@ module Spree
belongs_to :originator, polymorphic: true, optional: true
belongs_to :store_credit_reason, class_name: 'Spree::StoreCreditReason', inverse_of: :store_credit_events, optional: true
validates_presence_of :store_credit_reason, if: :action_requires_reason?
validates :store_credit_reason, presence: { if: :action_requires_reason? }
NON_EXPOSED_ACTIONS = [Spree::StoreCredit::ELIGIBLE_ACTION, Spree::StoreCredit::AUTHORIZE_ACTION]

View File

@ -11,7 +11,7 @@ module Spree
end
validates :name, presence: true
validates_uniqueness_of :name, case_sensitive: true, unless: :deleted_at
validates :name, uniqueness: { case_sensitive: true, unless: :deleted_at }
has_many :tax_rate_tax_categories,
class_name: 'Spree::TaxRateTaxCategory',

View File

@ -5,8 +5,8 @@ module Spree
belongs_to :user, class_name: UserClassHandle.new, foreign_key: "user_id", inverse_of: :user_addresses
belongs_to :address, class_name: "Spree::Address"
validates_uniqueness_of :address_id, scope: :user_id
validates_uniqueness_of :user_id, conditions: -> { default_shipping }, message: :default_address_exists, if: :default?
validates :address_id, uniqueness: { scope: :user_id }
validates :user_id, uniqueness: { conditions: -> { default_shipping }, message: :default_address_exists, if: :default? }
scope :with_address_values, ->(address_attributes) do
joins(:address).merge(

View File

@ -74,7 +74,7 @@ module Spree
validates :cost_price, numericality: { greater_than_or_equal_to: 0, allow_nil: true }
validates :price, numericality: { greater_than_or_equal_to: 0, allow_nil: true }
validates_uniqueness_of :sku, allow_blank: true, case_sensitive: true, conditions: -> { where(deleted_at: nil) }, if: :enforce_unique_sku?
validates :sku, uniqueness: { allow_blank: true, case_sensitive: true, conditions: -> { where(deleted_at: nil) }, if: :enforce_unique_sku? }
after_create :create_stock_items
after_create :set_master_out_of_stock, unless: :is_master?

View File

@ -5,6 +5,6 @@ module Spree
belongs_to :option_value, optional: true
belongs_to :variant_property_rule, touch: true, optional: true
validates_uniqueness_of :option_value_id, scope: :variant_property_rule_id
validates :option_value_id, uniqueness: { scope: :variant_property_rule_id }
end
end

View File

@ -5,8 +5,8 @@ module Spree
belongs_to :user, class_name: Spree::UserClassHandle.new, foreign_key: 'user_id', inverse_of: :wallet_payment_sources, optional: true
belongs_to :payment_source, polymorphic: true, inverse_of: :wallet_payment_sources, optional: true
validates_presence_of :user
validates_presence_of :payment_source
validates :user, presence: true
validates :payment_source, presence: true
validates :user_id, uniqueness: {
scope: [:payment_source_type, :payment_source_id],
message: :payment_source_already_exists

View File

@ -18,7 +18,7 @@ module Spree
MATCH_POLICIES = %w(any all none)
validates_inclusion_of :preferred_match_policy, in: MATCH_POLICIES
validates :preferred_match_policy, inclusion: { in: MATCH_POLICIES }
preference :match_policy, :string, default: MATCH_POLICIES.first

View File

@ -14,7 +14,7 @@ module Spree
MATCH_POLICIES = %w(any all none)
validates_inclusion_of :preferred_match_policy, in: MATCH_POLICIES
validates :preferred_match_policy, inclusion: { in: MATCH_POLICIES }
preference :match_policy, :string, default: MATCH_POLICIES.first
def applicable?(promotable)

View File

@ -2,7 +2,7 @@
module Spree
class PromotionCategory < Spree::Base
validates_presence_of :name
validates :name, presence: true
has_many :promotions
end
end

View File

@ -9,7 +9,7 @@ module Spree
has_many :promotion_codes, class_name: "Spree::PromotionCode", dependent: :destroy
validates :number_of_codes, numericality: { greater_than: 0 }
validates_presence_of :base_code, :number_of_codes
validates :base_code, :number_of_codes, presence: true
def finished?
state == "completed"