Showing 155 of 227 total issues
Method fill_status
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def fill_status(variant, quantity)
if item = stock_item_or_create(variant)
if item.count_on_hand >= quantity
on_hand = quantity
backordered = 0
- 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 by_properties
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def by_properties(products)
return products unless properties?
product_ids = []
index = 0
- 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_payment_preconditions
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def handle_payment_preconditions
unless block_given?
raise ArgumentError, 'handle_payment_preconditions must be called with a block'
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 create_shipments_from_params
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def self.create_shipments_from_params(shipments_hash, order)
return [] unless shipments_hash
shipments_hash.each do |s|
shipment = order.shipments.build
- 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_user_permissions
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def apply_user_permissions(user)
can :read, ::Spree::Country
can :read, ::Spree::Menu
can :read, ::Spree::CmsPage
can :read, ::Spree::OptionType
Method down
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def down
ActiveRecord::Base.connection.execute("
UPDATE #{PRODUCTS_TABLE} as products
SET (name,
description,
Method queue_webhooks_requests!
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def queue_webhooks_requests!(event_name)
return if disable_spree_webhooks?
return if Spree::Webhooks::Subscriber.none?
return if Spree::Webhooks::Subscriber.active.with_urls_for(event_name).none?
return if update_event?(event_name) && updating_only_ignored_attributes?
- 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 display_getter_methods
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def self.display_getter_methods(model_klazz)
model_klazz.new.methods.find_all do |method_name|
next unless method_name.to_s.start_with?('display_')
next if method_name.to_s.end_with?('=')
next if [Spree::Product, Spree::Variant].include?(model_klazz) && method_name == :display_amount
- 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 title
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def title
Spree::Deprecation.warn(<<-DEPRECATION, caller)
ControllerHelpers::Common is deprecated and will be removed in Spree 5.0.
DEPRECATION
title_string = @title.present? ? @title : accurate_title
- 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 11 (exceeds 5 allowed). Consider refactoring. Open
def eligible?(order, _options = {})
return true if eligible_products.empty?
if preferred_match_policy == 'all'
unless eligible_products.all? { |p| order.products.include?(p) }
- 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 link
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def link
case linked_resource_type
when 'Spree::Taxon'
return if linked_resource&.permalink.blank?
- 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 create_payments_from_params
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def self.create_payments_from_params(payments_hash, order)
return [] unless payments_hash
payments_hash.each do |p|
payment = order.payments.build order: 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 load_samples
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.load_samples
Spree::Webhooks.disable_webhooks do
Spree::Sample.load_sample('addresses')
Spree::Sample.load_sample('zones')
Spree::Sample.load_sample('payment_methods')
Method create_shipments_from_params
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.create_shipments_from_params(shipments_hash, order)
return [] unless shipments_hash
shipments_hash.each do |s|
shipment = order.shipments.build
Method import
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.import(user, params)
ensure_country_id_from_params params[:ship_address_attributes]
ensure_state_id_from_params params[:ship_address_attributes]
ensure_country_id_from_params params[:bill_address_attributes]
ensure_state_id_from_params params[:bill_address_attributes]
Method change
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def change
remove_index :spree_stock_items, name: 'stock_item_by_loc_var_id_deleted_at' if index_exists?(:spree_stock_items, [:stock_location_id, :variant_id], name: 'stock_item_by_loc_var_id_deleted_at')
unless index_exists?(:spree_stock_items, ['variant_id', 'stock_location_id'], name: 'index_spree_stock_items_unique_without_deleted_at')
# MySQL doesn't support partial indexes
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 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 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"