Showing 155 of 227 total issues

Method fill_status has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def fill_status(variant, quantity)
      if item = stock_item_or_create(variant)
        if item.count_on_hand >= quantity
          on_hand = quantity
          backordered = 0
Severity: Minor
Found in core/app/models/spree/stock_location.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 by_properties has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def by_properties(products)
        return products unless properties?

        product_ids = []
        index = 0
Severity: Minor
Found in core/app/finders/spree/products/find.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_payment_preconditions has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def handle_payment_preconditions
        unless block_given?
          raise ArgumentError, 'handle_payment_preconditions must be called with a block'
        end

Severity: Minor
Found in core/app/models/spree/payment/processing.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 create_shipments_from_params has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        def self.create_shipments_from_params(shipments_hash, order)
          return [] unless shipments_hash

          shipments_hash.each do |s|
            shipment = order.shipments.build
Severity: Minor
Found in core/lib/spree/core/importer/order.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 apply_user_permissions has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def apply_user_permissions(user)
      can :read, ::Spree::Country
      can :read, ::Spree::Menu
      can :read, ::Spree::CmsPage
      can :read, ::Spree::OptionType
Severity: Minor
Found in core/app/models/spree/ability.rb - About 1 hr to fix

    Method down has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def down
        ActiveRecord::Base.connection.execute("
          UPDATE #{PRODUCTS_TABLE} as products
          SET (name,
               description,

      Method queue_webhooks_requests! has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

              def queue_webhooks_requests!(event_name)
                return if disable_spree_webhooks?
                return if Spree::Webhooks::Subscriber.none?
                return if Spree::Webhooks::Subscriber.active.with_urls_for(event_name).none?
                return if update_event?(event_name) && updating_only_ignored_attributes?
      Severity: Minor
      Found in api/app/models/concerns/spree/webhooks/has_webhooks.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 display_getter_methods has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

              def self.display_getter_methods(model_klazz)
                model_klazz.new.methods.find_all do |method_name|
                  next unless method_name.to_s.start_with?('display_')
                  next if method_name.to_s.end_with?('=')
                  next if [Spree::Product, Spree::Variant].include?(model_klazz) && method_name == :display_amount

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

                def title
                  Spree::Deprecation.warn(<<-DEPRECATION, caller)
                    ControllerHelpers::Common is deprecated and will be removed in Spree 5.0.
                  DEPRECATION
                  title_string = @title.present? ? @title : accurate_title
      Severity: Minor
      Found in core/lib/spree/core/controller_helpers/common.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? has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

              def eligible?(order, _options = {})
                return true if eligible_products.empty?
      
                if preferred_match_policy == 'all'
                  unless eligible_products.all? { |p| order.products.include?(p) }
      Severity: Minor
      Found in core/app/models/spree/promotion/rules/product.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 link has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

            def link
              case linked_resource_type
              when 'Spree::Taxon'
                return if linked_resource&.permalink.blank?
      
      
      Severity: Minor
      Found in core/app/models/concerns/spree/display_link.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 create_payments_from_params has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

              def self.create_payments_from_params(payments_hash, order)
                return [] unless payments_hash
      
                payments_hash.each do |p|
                  payment = order.payments.build order: order
      Severity: Minor
      Found in core/lib/spree/core/importer/order.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 load_samples has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def self.load_samples
            Spree::Webhooks.disable_webhooks do
              Spree::Sample.load_sample('addresses')
              Spree::Sample.load_sample('zones')
              Spree::Sample.load_sample('payment_methods')
      Severity: Minor
      Found in sample/lib/spree_sample.rb - About 1 hr to fix

        Method create_shipments_from_params has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def self.create_shipments_from_params(shipments_hash, order)
                  return [] unless shipments_hash
        
                  shipments_hash.each do |s|
                    shipment = order.shipments.build
        Severity: Minor
        Found in core/lib/spree/core/importer/order.rb - About 1 hr to fix

          Method import has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  def self.import(user, params)
                    ensure_country_id_from_params params[:ship_address_attributes]
                    ensure_state_id_from_params params[:ship_address_attributes]
                    ensure_country_id_from_params params[:bill_address_attributes]
                    ensure_state_id_from_params params[:bill_address_attributes]
          Severity: Minor
          Found in core/lib/spree/core/importer/order.rb - About 1 hr to fix

            Method change has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def change
                remove_index :spree_stock_items, name: 'stock_item_by_loc_var_id_deleted_at' if index_exists?(:spree_stock_items, [:stock_location_id, :variant_id], name: 'stock_item_by_loc_var_id_deleted_at')
            
                unless index_exists?(:spree_stock_items, ['variant_id', 'stock_location_id'], name: 'index_spree_stock_items_unique_without_deleted_at')
                  # MySQL doesn't support partial indexes
            Severity: Minor
            Found in core/db/migrate/20240303174340_fix_spree_stock_item_unique_index.rb - About 1 hr to fix

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

              Severity
              Category
              Status
              Source
              Language