core/lib/spree/core/importer/order.rb

Summary

Maintainability
C
1 day
Test Coverage
A
94%

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

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

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

              def self.ensure_state_id_from_params(address)
                return if address.nil? || address[:state_id].present? || address[:state].nil?
      
                begin
                  search = {}
      Severity: Minor
      Found in core/lib/spree/core/importer/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 ensure_country_id_from_params has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def self.ensure_country_id_from_params(address)
                return if address.nil? || address[:country_id].present? || address[:country].nil?
      
                begin
                  search = {}
      Severity: Minor
      Found in core/lib/spree/core/importer/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

      There are no issues that match your filters.

      Category
      Status