Showing 155 of 227 total issues

Method process_payments_with has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

        def process_payments_with(method)
          # Don't run if there is nothing to pay.
          return if payment_total >= total
          # Prevent orders from transitioning to complete without a successfully processed payment.
          raise Core::GatewayError, Spree.t(:no_payment_found) if unprocessed_payments.empty?
Severity: Minor
Found in core/app/models/spree/order/payments.rb - About 2 hrs 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 convert_preference_value has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

  def convert_preference_value(value, type)
    case type
    when :string, :text
      value.to_s
    when :password
Severity: Minor
Found in core/lib/spree/core/preferences/preferable.rb - About 2 hrs 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

Class BaseController has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

      class BaseController < ActionController::API
        include CanCan::ControllerAdditions
        include Spree::Core::ControllerHelpers::StrongParameters
        include Spree::Core::ControllerHelpers::Store
        include Spree::Core::ControllerHelpers::Locale
Severity: Minor
Found in api/app/controllers/spree/api/v2/base_controller.rb - About 2 hrs to fix

    Method state_validate has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        def state_validate
          # Skip state validation without country (also required)
          # or when disabled by preference
          return if country.blank? || !Spree::Config[:address_requires_state]
          return unless country.states_required
    Severity: Minor
    Found in core/app/models/spree/address.rb - About 2 hrs 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 import has a Cognitive Complexity of 18 (exceeds 5 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 2 hrs 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

    Class Store has 22 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Store < Spree::Base
        include Spree::TranslatableResource
        if defined?(Spree::Webhooks::HasWebhooks)
          include Spree::Webhooks::HasWebhooks
        end
    Severity: Minor
    Found in core/app/models/spree/store.rb - About 2 hrs to fix

      File product_scopes.rb has 258 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      module Spree
        module ProductScopes
          extend ActiveSupport::Concern
      
          included do
      Severity: Minor
      Found in core/app/models/concerns/spree/product_scopes.rb - About 2 hrs to fix

        Class Zone has 21 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class Zone < Spree::Base
            include Spree::UniqueName
            if defined?(Spree::Webhooks::HasWebhooks)
              include Spree::Webhooks::HasWebhooks
            end
        Severity: Minor
        Found in core/app/models/spree/zone.rb - About 2 hrs to fix

          Method contains? has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              def contains?(target)
                return false if state? && target.country?
                return false if zone_members.empty? || target.zone_members.empty?
          
                if kind == target.kind
          Severity: Minor
          Found in core/app/models/spree/zone.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 insert_checkout_step has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

                    def self.insert_checkout_step(name, options = {})
                      before = options.delete(:before)
                      after = options.delete(:after) unless before
                      after = self.checkout_steps.keys.last unless before || after
          
          
          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 add_french_locales has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def add_french_locales
                  I18n.backend.store_translations(:fr,
                    spree: {
                      added_to_cart: 'Ajouté au panier avec succès!',
                      continue_shopping: 'Continuer vos achats',
          Severity: Minor
          Found in core/lib/spree/testing_support/locale_helpers.rb - About 1 hr to fix

            Method default_package has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                  def default_package
                    package = Package.new(stock_location)
            
                    # Group by variant_id as grouping by variant fires cached query.
                    inventory_units.index_by(&:variant_id).each do |variant_id, inventory_unit|
            Severity: Minor
            Found in core/app/models/spree/stock/packer.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 convert_preference_value has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def convert_preference_value(value, type)
                case type
                when :string, :text
                  value.to_s
                when :password
            Severity: Minor
            Found in core/lib/spree/core/preferences/preferable.rb - About 1 hr to fix

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

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

                Method money_methods has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                    def money_methods(*args)
                      args.each do |money_method|
                        money_method = { money_method => {} } unless money_method.is_a? Hash
                        money_method.each do |method_name, opts|
                          define_method("display_#{method_name}") do |**args_list|
                Severity: Minor
                Found in core/app/models/concerns/spree/display_money.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 meta_data has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                    def meta_data
                      meta = {}
                
                      if object.is_a? ApplicationRecord
                        meta[:keywords] = object.meta_keywords if object.try(:meta_keywords).present?
                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 update_payment_state has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                    def update_payment_state
                      last_state = order.payment_state
                      if payments.present? && payments.valid.empty?
                        order.payment_state = 'failed'
                      elsif order.canceled? && order.payment_total == 0
                Severity: Minor
                Found in core/app/models/spree/order_updater.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 call has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                      def call(order:, params:)
                        if params[:shipment_id].present?
                          shipment = order.shipments.valid.find_by(id: params[:shipment_id])
                          return failure(:shipment_not_found) if shipment.nil?
                        end
                Severity: Minor
                Found in core/app/services/spree/checkout/select_shipping_method.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 populate_seed_data has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                    def populate_seed_data
                      if @load_seed_data
                        say_status :loading,  'seed data'
                        rake_options = []
                        rake_options << 'AUTO_ACCEPT=1' if options[:auto_accept]
                Severity: Minor
                Found in core/lib/generators/spree/install/install_generator.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

                Severity
                Category
                Status
                Source
                Language