core/app/models/spree/order/checkout.rb

Summary

Maintainability
D
2 days
Test Coverage
A
95%

Method included has 231 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def self.included(klass)
        klass.class_eval do
          class_attribute :next_event_transitions
          class_attribute :previous_states
          class_attribute :checkout_flow
Severity: Major
Found in core/app/models/spree/order/checkout.rb - About 1 day to fix

    Method update_from_params has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

              def update_from_params(params, permitted_params, request_env = {})
                success = false
                @updating_params = params
                run_callbacks :updating_from_params do
                  # Set existing card after setting permitted parameters because
    Severity: Minor
    Found in core/app/models/spree/order/checkout.rb - About 3 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 define_state_machine! has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

              def self.define_state_machine!
                self.checkout_steps = {}
                self.next_event_transitions = []
                self.previous_states = [:cart]
                self.removed_transitions = []
    Severity: Minor
    Found in core/app/models/spree/order/checkout.rb - About 3 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 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 update_params_payment_source has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

              def update_params_payment_source
                if @updating_params[:payment_source].present?
                  source_params = @updating_params.
                                  delete(:payment_source)[@updating_params[:order][:payments_attributes].
                                  first[:payment_method_id].to_s]
    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 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 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

    There are no issues that match your filters.

    Category
    Status