Solidus/ClassEvalDecorator
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged | Required Solidus Version |
---|---|---|---|---|---|
Enabled | Yes | No | 0.1 | - | - |
Solidus suggests a decorator module instead of class_eval
when overriding some features.
This cop finds any class_eval
and asks to use a decorator module instead.
More info: https://guides.solidus.io/customization/customizing-the-core.
Examples
# bad
SpreeClass.class_eval do
# your code here
end
# good
module Spree
module SpreeClassDecorator
# your code here
end
Spree::SpreeClass.prepend self
end
References
Solidus/DiscountedAmountDeprecated
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged | Required Solidus Version |
---|---|---|---|---|---|
Enabled | Yes | No | «next» | - | 2.4 |
This cop finds .discounted_amount occurrences and suggest using .total_before_tax instead.
Examples
# bad
line_item.discounted_amount
# good
line_item.total_before_tax
References
Solidus/ExistingCardIdDeprecated
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged | Required Solidus Version |
---|---|---|---|---|---|
Enabled | Yes | No | 0.2 | - | 2.2 |
This cop finds existing_card_id occurrences and suggest using wallet_payment_source_id instead.
Examples
# bad
{
name: payment_method.name,
existing_card_id: payment_source.id
}
# good
{
name: payment_method.name,
wallet_payment_source_id: payment_source.wallet.wallet_payment_sources.first.id
}
References
Solidus/ReimbursementHookDeprecated
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged | Required Solidus Version |
---|---|---|---|---|---|
Enabled | Yes | No | 0.1 | - | 2.11 |
This cop finds reimbursement_success_hooks and reimbursement_failed_hooks calls and asks to remove them and subscribe to reimbursement_reimbursed event instead.
Examples
# bad
reimbursement_success_hooks.each { |h| h.call self }
reimbursement_failed_hooks.each { |h| h.call self }
# good
# bad
reimbursement_success_hooks.any?
reimbursement_failed_hooks.any?
# good
References
Solidus/SpreeCalculatorFreeShippingDeprecated
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged | Required Solidus Version |
---|---|---|---|---|---|
Enabled | Yes | No | 0.1 | - | - |
This cop finds Spree::Calculator::FreeShipping calls. This cop is needed as they have been deprecated in future version.
Examples
# bad
Spree::Calculator::FreeShipping
# good
References
Solidus/SpreeCalculatorPercentPerItemDeprecated
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged | Required Solidus Version |
---|---|---|---|---|---|
Enabled | Yes | Yes | 0.1 | - | - |
This cop finds Spree::Calculator::PercentPerItem calls. This cop is needed as they have been deprecated in future version.
Examples
# bad
Spree::Calculator::PercentPerItem
# good
Spree::Calculator::PercentOnLineItem
References
Solidus/SpreeCalculatorPriceSackDeprecated
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged | Required Solidus Version |
---|---|---|---|---|---|
Enabled | Yes | No | 0.1 | - | - |
This cop finds Spree::Calculator::PriceSack calls. This cop is needed as they have been deprecated in future version.
Examples
# bad
Spree::Calculator::PriceSack
# good
References
Solidus/SpreeDefaultCreditCardDeprecated
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged | Required Solidus Version |
---|---|---|---|---|---|
Enabled | Yes | No | 0.1 | - | 2.2 |
This cop finds user.default_credit_card suggest using user.wallet.default_wallet_payment_source.
Examples
# bad
user.default_credit_card
# good
user.wallet.default_wallet_payment_source
References
Solidus/SpreeGatewayBogusDeprecated
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged | Required Solidus Version |
---|---|---|---|---|---|
Enabled | Yes | Yes | 0.1 | - | 2.1 |
This cop finds Spree::Gateway::Bogus calls and replaces them with the Spree::PaymentMethod::BogusCreditCard. This cop is needed as the Spree::Gateway::Bogus has been deprecated in future version.
Examples
# bad
Spree::Gateway::Bogus.new
Spree::Gateway::Bogus.create
Spree::Gateway::Bogus.create!
# good
Spree::PaymentMethod::BogusCreditCard.new
Spree::PaymentMethod::BogusCreditCard.create
Spree::PaymentMethod::BogusCreditCard.create!
References
Solidus/SpreeIconDeprecated
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged | Required Solidus Version |
---|---|---|---|---|---|
Enabled | Yes | Yes | 0.1 | - | 2.3 |
This cop finds icon helper calls and suggest using solidus_icon.
Examples
# bad
helper.icon('example')
# good
helper.solidus_icon('example')
References
Solidus/SpreeRefundCallPerform
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged | Required Solidus Version |
---|---|---|---|---|---|
Enabled | Yes | No | 0.1 | - | 2.11 |
This cop finds Spree::Refund.create(your: attributes) calls and replaces them with the Spree::Refund.create(your: attributes, perform_after_create: false).perform! call.
Examples
# bad
Spree::Refund.create(your: attributes)
# good
Spree::Refund.create(your: attributes, perform_after_create: false).perform!
References
Solidus/SpreeTDeprecated
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged | Required Solidus Version |
---|---|---|---|---|---|
Enabled | Yes | Yes | 0.1 | - | - |
This cop finds Spree.t method calls and replaces them with the I18n,t method call. This cop is needed as the Spree.t version has been deprecated in future version.
Examples
# Without any parameters
# bad
Spree.t(:bar)
# good
I18n.t(:bar, scope: :spree)
# With the scope parameter
# bad
Spree.t(:bar, scope: [:city])
# good
I18n.t(:bar, scope: [:spree, :city])
# With the scope and other parameters
# bad
Spree.t(:bar, scope: [:city], email: email)
# good
I18n.t(:bar, scope: [:spree, :city], email: email)
# With the scope parameter as a string
# bad
Spree.t('bar', scope: 'admin.city')
# good
I18n.t('bar', scope: 'spree.admin.city')
References
Solidus/TaxCategoryDeprecated
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged | Required Solidus Version |
---|---|---|---|---|---|
Enabled | Yes | No | «next» | - | 2.2 |
This cop finds .tax_category occurrences and suggest using .tax_categories instead.
Examples
# bad
model.tax_category = data
# good
model.tax_categories = [data]