Showing 155 of 224 total issues
Method process_spree_action
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def process_spree_action(action, parameters = nil, session = nil, flash = nil, method = 'GET')
Method create_refunds
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def create_refunds(reimbursement, payments, unpaid_amount, simulate, reimbursement_list = [])
Method process_spree_xhr_action
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def process_spree_xhr_action(action, parameters = nil, session = nil, flash = nil, method = :get)
Method validate_source
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def validate_source
if source && !source.valid?
source.errors.map { |error| { field: error.attribute, message: error&.message } }.each do |err|
next if err[:field].blank? || err[:message].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 og_meta_data
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def og_meta_data
og_meta = {}
if object.is_a? Spree::Product
image = default_image_for_product_or_variant(object)
- 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 void_transaction!
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def void_transaction!
return true if void?
protect_from_connection_error do
if payment_method.payment_profiles_supported?
- 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 available
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.available(available_on = nil, currency = nil)
if available_on
scope = not_discontinued.where("#{Product.quoted_table_name}.available_on <= ?", available_on)
else
scope = where(status: 'active')
- 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 default_image_for_product_or_variant
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def default_image_for_product_or_variant(product_or_variant)
Rails.cache.fetch("spree/default-image/#{product_or_variant.cache_key_with_version}") do
if product_or_variant.is_a?(Spree::Product)
default_image_for_product(product_or_variant)
elsif product_or_variant.is_a?(Spree::Variant)
- 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 remove_item
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def remove_item(shipment:, variant:, quantity:)
result = remove_item_service.call(order: shipment.order,
variant: variant,
quantity: quantity,
options: { shipment: shipment })
- 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 calculate_reimbursement_type
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def calculate_reimbursement_type(return_item)
return exchange_reimbursement_type if return_item.exchange_required?
return return_item.override_reimbursement_type.class if return_item.override_reimbursement_type.present?
if return_item.preferred_reimbursement_type.present?
return valid_preferred_reimbursement_type?(return_item) ? return_item.preferred_reimbursement_type.class : 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 update_or_create_address
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def update_or_create_address(attributes = {})
return if attributes.blank?
attributes.transform_values! { |v| v == '' ? nil : v }
attributes = attributes.to_h.symbolize_keys
- 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 copy_price
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def copy_price
if variant
update_price if price.nil?
self.cost_price = variant.cost_price if cost_price.nil?
self.currency = variant.currency if currency.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 capture
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def capture(amount, authorization_code, order_currency, options = {})
return false unless authorize(amount, order_currency, action_authorization_code: authorization_code)
if amount <= amount_authorized
if currency != order_currency
- 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 call
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def call(order:)
return failed unless order
ApplicationRecord.transaction do
order.payments.checkout.store_credits.map(&:invalidate!) unless order.completed?
- 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 change
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def change
if Spree.user_class.present?
users_table_name = Spree.user_class.table_name
add_column users_table_name, :first_name, :string unless column_exists?(users_table_name, :first_name)
add_column users_table_name, :last_name, :string unless column_exists?(users_table_name, :last_name)
- 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 7 (exceeds 5 allowed). Consider refactoring. Open
def eligible?(order, options = {})
@user = order.try(:user) || options[:user]
@email = order.email
@store = order.store
- 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_refunds
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def create_refunds(reimbursement, payments, unpaid_amount, simulate, reimbursement_list = [])
payments.each do |payment|
break if unpaid_amount <= 0
next unless payment.can_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 apply
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def apply
if order.coupon_code.present?
if promotion.present? && promotion.actions.exists?
handle_present_promotion
elsif store.promotions.with_coupon_code(order.coupon_code).try(:expired?)
- 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_property
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def set_property(property_name, property_value, property_presentation = property_name)
ApplicationRecord.transaction do
# Manual first_or_create to work around Mobility bug
property = if Property.where(name: property_name).exists?
existing_property = Property.where(name: property_name).first
- 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 validate
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def validate(line_item)
unit_count = line_item.inventory_units.reject(&:pending?).sum(&:quantity)
return if unit_count >= line_item.quantity
quantity = line_item.quantity - unit_count
- 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"