Showing 155 of 224 total issues

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 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 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 download has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

          def download
            if attachment.present?
              if digital_link.authorize!
                if defined?(ActiveStorage::Service::DiskService) && ActiveStorage::Blob.service.instance_of?(ActiveStorage::Service::DiskService)
                  # The asset is hosted on disk, use send_file.
Severity: Minor
Found in api/app/controllers/spree/api/v2/storefront/digitals_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 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 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_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 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 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_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 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 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 expiry= has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def expiry=(expiry)
            return unless expiry.present?
      
            self[:month], self[:year] =
              if expiry =~ /\d{2}\s?\/\s?\d{2,4}/ # will match mm/yy and mm / yyyy
      Severity: Minor
      Found in core/app/models/spree/credit_card.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 ensure_current_store has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

              def ensure_current_store(object)
                return if object.nil?
      
                if object.has_attribute?(:store_id)
                  if object.store.present? && object.store != current_store
      Severity: Minor
      Found in core/lib/spree/core/controller_helpers/store.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 check_price has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def check_price
            if price.nil? && Spree::Config[:require_master_price]
              return errors.add(:base, :no_master_variant_found_to_infer_price)  unless product&.master
              return errors.add(:base, :must_supply_price_for_variant_or_master) if self == product.master
      
      
      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 current_order has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

              def current_order(options = {})
                options[:create_order_if_necessary] ||= false
                options[:includes] ||= true
      
                if @current_order
      Severity: Minor
      Found in core/lib/spree/core/controller_helpers/order.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 app_migrations has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def app_migrations
            Dir.entries(app_dir).map do |file_name|
              next if ['.', '..'].include? file_name
      
              name = file_name.split('_', 2).last
      Severity: Minor
      Found in core/lib/spree/migrations.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