core/app/models/spree/shipment.rb

Summary

Maintainability
C
1 day
Test Coverage
A
96%

Class Shipment has 40 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Shipment < Spree::Base
    include Spree::Core::NumberGenerator.new(prefix: 'H', length: 11)
    include Spree::NumberIdentifier
    include Spree::NumberAsParam
    include Spree::Metadata
Severity: Minor
Found in core/app/models/spree/shipment.rb - About 5 hrs to fix

    File shipment.rb has 292 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'ostruct'
    
    module Spree
      class Shipment < Spree::Base
        include Spree::Core::NumberGenerator.new(prefix: 'H', length: 11)
    Severity: Minor
    Found in core/app/models/spree/shipment.rb - About 3 hrs to fix

      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

      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 set_up_inventory has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Wontfix

          def set_up_inventory(state, variant, order, line_item, quantity = 1)
      Severity: Minor
      Found in core/app/models/spree/shipment.rb - About 35 mins to fix

        Method process_order_payments has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def process_order_payments
              pending_payments = order.pending_payments.
                                 sort_by(&:uncaptured_amount).reverse
        
              shipment_to_pay = final_price_with_items
        Severity: Minor
        Found in core/app/models/spree/shipment.rb - About 25 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