Showing 189 of 299 total issues

Function css_browser_selector has a Cognitive Complexity of 363 (exceeds 5 allowed). Consider refactoring.
Open

function css_browser_selector(u)
    {
    var    uaInfo = {},
        screens = [320, 480, 640, 768, 1024, 1152, 1280, 1440, 1680, 1920, 2560],
        allScreens = screens.length,
Severity: Minor
Found in guides/content/assets/javascripts/css_browser_selector_dev.js - About 1 wk 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 resources.rb has 1038 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'pp'
require 'yajl/json_gem'
require 'stringio'
require 'cgi'

Severity: Major
Found in guides/lib/resources.rb - About 2 days to fix

    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 84 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 519 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          require 'spree/core/validators/email'
          require 'spree/order/checkout'
          
          module Spree
            class Order < Spree::Base
          Severity: Major
          Found in core/app/models/spree/order.rb - About 1 day 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 Product has 41 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 5 hrs to fix

                Function onload has 134 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                window.onload = function() {
                
                  // Polygon drawing
                  function polygon(x, y, size, sides, rotate) {
                    var self = this;
                Severity: Major
                Found in guides/content/assets/javascripts/api-objects.js - 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

                    var initProductActions = function () {
                      /* globals Handlebars */
                      'use strict';
                    
                      // Add classes on promotion items for design
                    Severity: Major
                    Found in backend/app/assets/javascripts/spree/backend/promotions.js - About 5 hrs to fix

                      Function css_browser_selector has 110 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function css_browser_selector(u)
                          {
                          var    uaInfo = {},
                              screens = [320, 480, 640, 768, 1024, 1152, 1280, 1440, 1680, 1920, 2560],
                              allScreens = screens.length,
                      Severity: Major
                      Found in guides/content/assets/javascripts/css_browser_selector_dev.js - About 4 hrs to fix

                        Class Variant has 31 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 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 307 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

                            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 shipments.js has 304 lines of code (exceeds 250 allowed). Consider refactoring.
                              Open

                              // Shipments AJAX API
                              $(document).ready(function () {
                                'use strict';
                              
                                // handle variant selection, show stock level.
                              Severity: Minor
                              Found in backend/app/assets/javascripts/spree/backend/shipments.js - About 3 hrs to fix

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

                                    Severity
                                    Category
                                    Status
                                    Source