Showing 211 of 224 total issues

Method adjust has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def adjust(package_to_adjust, item)
        if fulfilled?
          package_to_adjust.remove_item item
        elsif item.backordered?
          # We only use the first backorder item to fill backorders
Severity: Minor
Found in core/app/models/spree/stock/adjuster.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 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 determine_state has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def determine_state(order)
      return 'canceled' if order.canceled?
      return 'pending' unless order.can_ship?
      return 'pending' if inventory_units.any? &:backordered?
      return 'shipped' if shipped?
Severity: Minor
Found in core/app/models/spree/shipment.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_default_country has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def ensure_default_country
      return unless has_attribute?(:default_country_id)
      return if default_country.present? && (checkout_zone.blank? || checkout_zone.country_list.blank? || checkout_zone.country_list.include?(default_country))

      self.default_country = if checkout_zone.present? && checkout_zone.country_list.any?
Severity: Minor
Found in core/app/models/spree/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 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

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

Method checkout_steps has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

          def checkout_steps
            steps = (self.class.checkout_steps.each_with_object([]) do |(step, options), checkout_steps|
              next if options.include?(:if) && !options[:if].call(self)

              checkout_steps << step
Severity: Minor
Found in core/app/models/spree/order/checkout.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 call has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def call(address:, address_params:)
        address_params[:country_id] ||= address.country_id
        address_params = fill_country_and_state_ids(address_params)
        address_params[:user_id] = address.user_id if address.user_id.present?

Severity: Minor
Found in core/app/services/spree/addresses/update.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 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 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 prepare has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def prepare(params)
          @properties[:keywords] = params[:keywords]
          @properties[:option_value_ids] = build_option_value_ids(params)
          @properties[:price] = get_price_range(params[:price])
          @properties[:search] = params[:search]
Severity: Minor
Found in core/lib/spree/core/search/base.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 create_line_items_from_params has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def self.create_line_items_from_params(line_items, order)
          return {} unless line_items

          line_items.each do |line_item|
            adjustments = line_item.delete(:adjustments_attributes)
Severity: Minor
Found in core/lib/spree/core/importer/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

Consider simplifying this complex logical expression.
Open

      if value.is_a?(FalseClass) ||
          value.nil? ||
          value == 0 ||
          value&.to_s =~ /^(f|false|0)$/i ||
          (value.respond_to?(:empty?) && value.empty?)
Severity: Major
Found in core/lib/spree/core/preferences/preferable.rb - About 40 mins to fix

    Method process_spree_action has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          def process_spree_action(action, parameters = nil, session = nil, flash = nil, method = 'GET')
    Severity: Minor
    Found in core/lib/spree/testing_support/controller_requests.rb - About 35 mins to fix

      Method process_spree_xhr_action has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

            def process_spree_xhr_action(action, parameters = nil, session = nil, flash = nil, method = :get)
      Severity: Minor
      Found in core/lib/spree/testing_support/controller_requests.rb - About 35 mins to fix

        Method create_refunds has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def create_refunds(reimbursement, payments, unpaid_amount, simulate, reimbursement_list = [])
        Severity: Minor
        Found in core/app/models/spree/reimbursement_type/reimbursement_helpers.rb - About 35 mins to fix

          Method change has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def change
              if Spree.user_class.present?
                users_table_name = Spree.user_class.table_name
                add_column users_table_name, :first_name, :string unless column_exists?(users_table_name, :first_name)
                add_column users_table_name, :last_name, :string unless column_exists?(users_table_name, :last_name)

          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 7 (exceeds 5 allowed). Consider refactoring.
          Open

                  def eligible?(order, options = {})
                    @user = order.try(:user) || options[:user]
                    @email = order.email
                    @store = order.store
          
          
          Severity: Minor
          Found in core/app/models/spree/promotion/rules/first_order.rb - About 35 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 call has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                def call(order:)
                  return failed unless order
          
                  ApplicationRecord.transaction do
                    order.payments.checkout.store_credits.map(&:invalidate!) unless order.completed?
          Severity: Minor
          Found in core/app/services/spree/checkout/remove_store_credit.rb - About 35 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