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)
Severity: Minor
Found in core/app/models/spree/promotion_handler/coupon.rb - About 1 hr to fix

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]
Severity: Minor
Found in core/app/models/spree/order/checkout.rb - About 1 hr to fix

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) }
Severity: Minor
Found in core/app/models/spree/promotion.rb - About 1 hr to fix

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
Severity: Minor
Found in core/app/models/spree/shipment.rb - About 1 hr to fix

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
Severity: Minor
Found in core/app/models/spree/promotion.rb - About 1 hr to fix

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
Severity: Minor
Found in core/lib/spree/testing_support/order_walkthrough.rb - About 1 hr to fix

    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
      Severity: Minor
      Found in core/lib/spree/testing_support/i18n.rb - About 55 mins to fix

      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')
      
      
      Severity: Minor
      Found in core/app/models/concerns/spree/product_scopes.rb - About 55 mins to fix

      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)
      Severity: Minor
      Found in core/app/models/spree/calculator/price_sack.rb - About 55 mins to fix

      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
      Severity: Minor
      Found in core/app/models/spree/cms/sections/image_gallery.rb - About 55 mins to fix

      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
      Severity: Minor
      Found in core/app/models/spree/calculator/tiered_percent.rb - About 55 mins to fix

      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
      
      
      Severity: Minor
      Found in core/app/models/spree/stock_item.rb - About 55 mins to fix

      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
      Severity: Minor
      Found in core/app/models/spree/promotion/actions/create_line_items.rb - About 55 mins to fix

      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)
      Severity: Minor
      Found in core/lib/spree/migrations.rb - About 55 mins to fix

      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
      Severity: Minor
      Found in core/app/models/spree/order/checkout.rb - About 55 mins to fix

      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)
      Severity: Minor
      Found in core/app/models/spree/refund.rb - About 45 mins to fix

      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|
      Severity: Minor
      Found in core/app/services/spree/checkout/add_store_credit.rb - About 45 mins to fix

      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|
      Severity: Minor
      Found in core/app/models/spree/variant.rb - About 45 mins to fix

      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
      Severity: Minor
      Found in core/app/models/spree/promotion/rules/taxon.rb - About 45 mins to fix

      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

      Severity
      Category
      Status
      Source
      Language