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)
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 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 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 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

Severity: Minor
Found in core/app/helpers/spree/base_helper.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 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?
Severity: Minor
Found in core/app/models/spree/order_inventory.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 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 =
Severity: Minor
Found in api/app/controllers/spree/api/v2/platform/shipments_controller.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 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 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 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 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 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 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 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 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 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 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 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

      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
      Severity: Minor
      Found in core/app/models/spree/order_merger.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