Showing 184 of 807 total issues

Method up has 410 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/20120831092320_spree_one_two.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

      Method included has 239 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

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

        require 'spree/order/checkout'
        
        module Spree
          class Order < Spree::Base
            PAYMENT_STATES = %w(balance_due credit_owed failed paid void)
        Severity: Major
        Found in core/app/models/spree/order.rb - About 1 day to fix

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

            class Product < Spree::Base
              extend FriendlyId
              include ActsAsTaggable
              friendly_id :slug_candidates, use: :history
          
          
          Severity: Minor
          Found in core/app/models/spree/product.rb - About 6 hrs to fix

            File 20120831092320_spree_one_two.rb has 414 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            class SpreeOneTwo < ActiveRecord::Migration[4.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: Minor
            Found in core/db/migrate/20120831092320_spree_one_two.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 NumberAsParam
              
              
              Severity: Minor
              Found in core/app/models/spree/shipment.rb - About 5 hrs to fix

                Function initProductActions has 126 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function initProductActions () {
                  'use strict'
                
                  // Add classes on promotion items for design
                  $(document).on('mouseover mouseout', 'a.delete', function (event) {
                Severity: Major
                Found in backend/app/assets/javascripts/spree/backend/promotions.js - About 5 hrs to fix

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

                    class Variant < Spree::Base
                      acts_as_paranoid
                      acts_as_list scope: :product
                  
                      belongs_to :product, touch: true, class_name: 'Spree::Product', inverse_of: :variants
                  Severity: Minor
                  Found in core/app/models/spree/variant.rb - About 4 hrs to fix

                    Function onAddress has 95 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      Spree.onAddress = function () {
                        if ($('#checkout_form_address').length) {
                          Spree.updateState = function (region) {
                            var countryId = getCountryId(region)
                            if (countryId != null) {
                    Severity: Major
                    Found in frontend/app/assets/javascripts/spree/frontend/checkout/address.js - About 3 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

                      File admin.js has 315 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      /**
                      This is a collection of javascript functions and whatnot
                      under the spree namespace that do stuff we find helpful.
                      Hopefully, this will evolve into a propper class.
                      **/
                      Severity: Minor
                      Found in backend/app/assets/javascripts/spree/backend/admin.js - About 3 hrs to fix

                        File shipments.js has 306 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        /* global shipments, variantStockTemplate, order_number */
                        // Shipments AJAX API
                        $(document).ready(function () {
                          'use strict'
                        
                        
                        Severity: Minor
                        Found in backend/app/assets/javascripts/spree/backend/shipments.js - About 3 hrs to fix

                          Class ResourceController has 28 methods (exceeds 20 allowed). Consider refactoring.
                          Open

                          class Spree::Admin::ResourceController < Spree::Admin::BaseController
                            include Spree::Backend::Callbacks
                          
                            helper_method :new_object_url, :edit_object_url, :object_url, :collection_url
                            before_action :load_resource, except: :update_positions
                          Severity: Minor
                          Found in backend/app/controllers/spree/admin/resource_controller.rb - About 3 hrs to fix

                            File shipment.rb has 295 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

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

                              module Spree
                                class Product < Spree::Base
                                  extend FriendlyId
                                  include ActsAsTaggable
                                  friendly_id :slug_candidates, use: :history
                              Severity: Minor
                              Found in core/app/models/spree/product.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)
                                
                                    class_attribute :return_eligibility_validator
                                    self.return_eligibility_validator = ReturnItem::EligibilityValidator::Default
                                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

                                  Method up has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                    def up
                                      add_column :spree_products, :discontinue_on, :datetime, after: :available_on
                                      add_column :spree_variants, :discontinue_on, :datetime, after: :deleted_at
                                  
                                      add_index :spree_products, :discontinue_on

                                  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 BaseController has 24 methods (exceeds 20 allowed). Consider refactoring.
                                  Open

                                      class BaseController < ActionController::Base
                                        protect_from_forgery unless: -> { request.format.json? || request.format.xml? }
                                  
                                        include Spree::Api::ControllerSetup
                                        include Spree::Core::ControllerHelpers::Store
                                  Severity: Minor
                                  Found in api/app/controllers/spree/api/base_controller.rb - About 2 hrs to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language