Showing 156 of 228 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 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 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 spree_storefront_resource_url
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def spree_storefront_resource_url(resource, options = {})
if defined?(locale_param) && locale_param.present?
options.merge!(locale: locale_param)
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 verify
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def verify(shipment = nil, is_updated: false)
return unless order.completed? || shipment.present?
units_count = inventory_units.reload.sum(&:quantity)
line_item_changed = is_updated ? !line_item.saved_changes? : !line_item.changed?
- 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 transfer_to_shipment
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def transfer_to_shipment
target_shipment = Spree::Shipment.find_by!(number: params.dig(:shipment, :target_shipment_number))
quantity = params.dig(:shipment, :quantity)&.to_i || 1
error =
- 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 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 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 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 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 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 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 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 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 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 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 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"
Further reading
Method handle_merge
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def handle_merge(current_line_item, other_order_line_item)
if current_line_item
current_line_item.quantity += other_order_line_item.quantity
handle_error(current_line_item) unless current_line_item.save
else
- 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"