Showing 156 of 228 total issues
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 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 ensure_state_id_from_params
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.ensure_state_id_from_params(address)
return if address.nil? || address[:state_id].present? || address[:state].nil?
begin
search = {}
- 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 ensure_country_id_from_params
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.ensure_country_id_from_params(address)
return if address.nil? || address[:country_id].present? || address[:country].nil?
begin
search = {}
- 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 get
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def get(key)
# return the retrieved value, if it's in the cache
# use unless nil? in case the value is actually boolean false
#
unless (val = @cache.read(key)).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
Avoid too many return
statements within this method. Open
return false if (target.states.pluck(:country_id) - countries.pluck(:id)).present?
Avoid too many return
statements within this method. Open
return if webhook_payload_body.blank?
Method process_order_payments
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def process_order_payments
pending_payments = order.pending_payments.
sort_by(&:uncaptured_amount).reverse
shipment_to_pay = final_price_with_items
- 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 postal_code_validate
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def postal_code_validate
return if country.blank? || country_iso.blank? || !require_zipcode? || zipcode.blank?
return unless ::ValidatesZipcode::CldrRegexpCollection::ZIPCODES_REGEX.keys.include?(country_iso.upcase.to_sym)
formatted_zip = ::ValidatesZipcode::Formatter.new(
- 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_actions
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def copy_actions
@promotion.promotion_actions.each do |action|
new_action = action.dup
new_action.calculator = action.calculator.dup if action.try(:calculator)
- 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_to_tracking
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def link_to_tracking(shipment, options = {})
return unless shipment.tracking && shipment.shipping_method
options[:target] ||= :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 build_source
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def build_source
return unless new_record?
if source_attributes.present? && source.blank? && payment_method.try(:payment_source_class)
self.source = payment_method.payment_source_class.new(source_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 authorize
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def authorize(amount, order_currency, options = {})
authorization_code = options[:action_authorization_code]
if authorization_code
if store_credit_events.find_by(action: AUTHORIZE_ACTION, authorization_code: authorization_code)
# Don't authorize again on capture
- 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 price_in
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def price_in(currency)
currency = currency&.upcase
find_or_build_price = lambda do
if prices.loaded?
prices.detect { |price| price.currency == currency } || prices.build(currency: 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 change
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def change
if table_exists?(:spree_wishlists)
rename_column(:spree_wishlists, :access_hash, :token) if column_exists?(:spree_wishlists, :access_hash)
add_reference(:spree_wishlists, :store, index: true) unless column_exists?(:spree_wishlists, :store_id)
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 store_image_url_for
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.store_image_url_for(store, attribute_name)
attachment = store.send(attribute_name)&.attachment
return unless attachment&.attached?
url_helpers = Rails.application.routes.url_helpers
- 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_rules
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def copy_rules
@promotion.promotion_rules.each do |rule|
new_rule = rule.dup
@new_promotion.promotion_rules << new_rule
- 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 6 (exceeds 5 allowed). Consider refactoring. Open
def change
create_table :spree_wished_products, if_not_exists: true do |t|
t.references :variant
t.belongs_to :wishlist
- 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 6 (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 ordered
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def ordered(products)
return products unless sort_by?
case sort_by
when 'default'
- 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"