Showing 155 of 227 total issues
Method handle_present_promotion
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def handle_present_promotion
return promotion_usage_limit_exceeded if promotion.usage_limit_exceeded?(order)
return promotion_applied if promotion_exists_on_order?
unless promotion.eligible?(order)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method update_params_payment_source
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def update_params_payment_source
if @updating_params[:payment_source].present?
source_params = @updating_params.
delete(:payment_source)[@updating_params[:order][:payments_attributes].
first[:payment_method_id].to_s]
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method eligible_rules
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def eligible_rules(promotable, options = {})
# Promotions without rules are eligible by default.
return [] if rules.none?
specific_rules = rules.select { |rule| rule.applicable?(promotable) }
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method refresh_rates
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def refresh_rates(shipping_method_filter = ShippingMethod::DISPLAY_ON_FRONT_END)
return shipping_rates if shipped?
return [] unless can_get_rates?
# StockEstimator.new assignment below will replace the current shipping_method
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method line_item_actionable?
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def line_item_actionable?(order, line_item)
if eligible? order
rules = eligible_rules(order)
if rules.blank?
true
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method up_to
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.up_to(state, store = nil)
store ||= if Spree::Store.exists?
# Ensure the default store is used
Spree::Store.default || FactoryBot.create(:store, default: true)
else
Method change
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def change
%i[
spree_assets
spree_option_types
spree_option_values
Method check_missing_translations
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.check_missing_translations
self.missing_translation_messages = []
self.used_translations ||= []
used_translations.map { |a| a.split('.') }.each do |translation_keys|
root = translations
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method add_simple_scopes
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.add_simple_scopes(scopes)
scopes.each do |name|
# We should not define price scopes here, as they require something slightly different
next if name.to_s.include?('master_price')
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method compute
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def compute(object)
base = if object.is_a?(Array)
object.map { |o| o.respond_to?(:amount) ? o.amount : BigDecimal(o.to_s) }.sum
else
object.respond_to?(:amount) ? object.amount : BigDecimal(object.to_s)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method reset_multiple_link_attributes
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def reset_multiple_link_attributes
if link_type_one_changed?
return if link_type_one_was.nil?
self.link_one = nil
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method preferred_tiers_content
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def preferred_tiers_content
if preferred_tiers.is_a? Hash
unless preferred_tiers.keys.all? { |k| k.is_a?(Numeric) && k > 0 }
errors.add(:base, :keys_should_be_positive_number)
end
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method process_backorders
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def process_backorders(number)
return unless number.positive?
units = backordered_inventory_units.first(number) # We can process atmost n backorders
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method perform
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def perform(options = {})
order = options[:order]
return unless eligible? order
action_taken = false
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method check
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def check
if File.directory?(app_dir)
engine_in_app = app_migrations.map do |file_name|
name, engine = file_name.split('.', 2)
next unless match_engine?(engine)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method assign_default_addresses!
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def assign_default_addresses!
if user
self.bill_address = user.bill_address if !bill_address_id && user.bill_address&.valid?
# Skip setting ship address if order doesn't have a delivery checkout step
# to avoid triggering validations on shipping address
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method process!
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def process!(credit_cents)
response = if payment.payment_method.payment_profiles_supported?
payment.payment_method.credit(credit_cents, payment.source, payment.transaction_id, originator: self)
else
payment.payment_method.credit(credit_cents, payment.transaction_id, originator: self)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method apply_store_credits
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def apply_store_credits(remaining_total)
payment_method = Spree::PaymentMethod::StoreCredit.available.first
raise 'Store credit payment method could not be found' unless payment_method
@order.user.store_credits.for_store(@order.store).order_by_priority.each do |credit|
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method set_option_value
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def set_option_value(opt_name, opt_value)
# no option values on master
return if is_master
option_type = Spree::OptionType.where(['LOWER(name) = ?', opt_name.downcase.strip]).first_or_initialize do |o|
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method eligible?
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def eligible?(order, _options = {})
if preferred_match_policy == 'all'
unless (taxons.to_a - taxons_in_order_including_parents(order)).empty?
eligibility_errors.add(:base, eligibility_error_message(:missing_taxon))
end
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"