Showing 155 of 227 total issues

Method up has 1116 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def up
    # This migration is just a compressed version of all the previous
    # migrations for spree_core. Do not run it if one of the core tables
    # already exists. Assume the best.
    return if data_source_exists?(:spree_addresses)
Severity: Major
Found in core/db/migrate/20210914000000_spree_four_three.rb - About 5 days to fix

    File 20210914000000_spree_four_three.rb has 1120 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class SpreeFourThree < ActiveRecord::Migration[5.2]
      def up
        # This migration is just a compressed version of all the previous
        # migrations for spree_core. Do not run it if one of the core tables
        # already exists. Assume the best.
    Severity: Major
    Found in core/db/migrate/20210914000000_spree_four_three.rb - About 2 days to fix

      Class Order has 89 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class Order < Spree::Base
          PAYMENT_STATES = %w(balance_due credit_owed failed paid void)
          SHIPMENT_STATES = %w(backorder canceled partial pending ready shipped)
      
          include Spree::Order::Checkout
      Severity: Major
      Found in core/app/models/spree/order.rb - About 1 day to fix

        File order.rb has 564 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require_dependency 'spree/order/checkout'
        require_dependency 'spree/order/currency_updater'
        require_dependency 'spree/order/digital'
        require_dependency 'spree/order/payments'
        require_dependency 'spree/order/store_credit'
        Severity: Major
        Found in core/app/models/spree/order.rb - About 1 day to fix

          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

            Class Product has 58 methods (exceeds 20 allowed). Consider refactoring.
            Open

              class Product < Spree::Base
                extend FriendlyId
                include ProductScopes
                include MultiStoreResource
                include TranslatableResource
            Severity: Major
            Found in core/app/models/spree/product.rb - About 1 day to fix

              File product.rb has 405 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              module Spree
                class Product < Spree::Base
                  extend FriendlyId
                  include ProductScopes
                  include MultiStoreResource
              Severity: Minor
              Found in core/app/models/spree/product.rb - About 5 hrs to fix

                Class Variant has 41 methods (exceeds 20 allowed). Consider refactoring.
                Open

                  class Variant < Spree::Base
                    acts_as_paranoid
                    acts_as_list scope: :product
                
                    include MemoizedData
                Severity: Minor
                Found in core/app/models/spree/variant.rb - About 5 hrs to fix

                  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 NumberIdentifier
                      include NumberAsParam
                      include Metadata
                  Severity: Minor
                  Found in core/app/models/spree/shipment.rb - About 5 hrs to fix

                    Class Find has 33 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                        class Find
                          def initialize(scope:, params:, current_currency: nil)
                            @scope = scope
                    
                            if current_currency.present?
                    Severity: Minor
                    Found in core/app/finders/spree/products/find.rb - About 4 hrs 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

                      Class CartController has 29 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                              class CartController < ::Spree::Api::V2::BaseController
                                include OrderConcern
                                include CouponCodesHelper
                                include Spree::Api::V2::Storefront::MetadataControllerConcern
                      
                      
                      Severity: Minor
                      Found in api/app/controllers/spree/api/v2/storefront/cart_controller.rb - About 3 hrs to fix

                        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

                        Class Payment has 27 methods (exceeds 20 allowed). Consider refactoring.
                        Open

                          class Payment < Spree::Base
                            include Spree::Core::NumberGenerator.new(prefix: 'P', letters: true, length: 7)
                            include NumberIdentifier
                            include NumberAsParam
                            include Metadata
                        Severity: Minor
                        Found in core/app/models/spree/payment.rb - About 3 hrs to fix

                          Method call has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                          Open

                                def call
                                  Spree::Country.where(states_required: true).each do |country|
                                    carmen_country = Carmen::Country.named(country.name)
                                    next unless carmen_country
                          
                          
                          Severity: Minor
                          Found in core/app/services/spree/seeds/states.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

                          File variant.rb has 293 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          module Spree
                            class Variant < Spree::Base
                              acts_as_paranoid
                              acts_as_list scope: :product
                          
                          
                          Severity: Minor
                          Found in core/app/models/spree/variant.rb - About 3 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

                              Class ReturnItem has 26 methods (exceeds 20 allowed). Consider refactoring.
                              Open

                                class ReturnItem < Spree::Base
                                  COMPLETED_RECEPTION_STATUSES = %w(received given_to_customer)
                              
                                  if defined?(Spree::Webhooks::HasWebhooks)
                                    include Spree::Webhooks::HasWebhooks
                              Severity: Minor
                              Found in core/app/models/spree/return_item.rb - About 3 hrs to fix

                                Method remove_from_shipment has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    def remove_from_shipment(shipment, quantity)
                                      return 0 if quantity.zero? || shipment.shipped?
                                
                                      shipment_units = shipment.inventory_units_for_item(line_item, variant).reject(&:shipped?).sort_by(&:state)
                                
                                
                                Severity: Minor
                                Found in core/app/models/spree/order_inventory.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 OrdersController has 24 methods (exceeds 20 allowed). Consider refactoring.
                                Open

                                        class OrdersController < ResourceController
                                          include CouponCodesHelper
                                          include NumberResource
                                
                                          def create
                                Severity: Minor
                                Found in api/app/controllers/spree/api/v2/platform/orders_controller.rb - About 2 hrs to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language