Showing 3,724 of 3,783 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

Assignment Branch Condition size for included is too high. [294.7/45]
Open

      def self.included(klass)
        klass.class_eval do
          class_attribute :next_event_transitions
          class_attribute :previous_states
          class_attribute :checkout_flow

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Class has too many lines. [513/150]
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: Minor
Found in core/app/models/spree/order.rb by rubocop

This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [239/50]
Open

      def self.included(klass)
        klass.class_eval do
          class_attribute :next_event_transitions
          class_attribute :previous_states
          class_attribute :checkout_flow

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

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

    File order_spec.rb has 898 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'spec_helper'
    
    class FakeCalculator < Spree::Calculator
      def compute(_computable)
        5
    Severity: Major
    Found in core/spec/models/spree/order_spec.rb - About 2 days to fix

      Class has too many lines. [302/150]
      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 by rubocop

      This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

      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

        Block has too many lines. [237/50]
        Open

                klass.class_eval do
                  class_attribute :next_event_transitions
                  class_attribute :previous_states
                  class_attribute :checkout_flow
                  class_attribute :checkout_steps

        This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

        Class has too many lines. [269/150]
        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 by rubocop

        This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

        File payment_spec.rb has 745 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require 'spec_helper'
        
        describe Spree::Payment, type: :model do
          let(:order) { Spree::Order.create }
          let(:refund_reason) { create(:refund_reason) }
        Severity: Major
        Found in core/spec/models/spree/payment_spec.rb - About 1 day to fix

          Class has too many lines. [228/150]
          Open

                class Order
                  def self.import(user, params)
          
                    ensure_country_id_from_params params[:ship_address_attributes]
                    ensure_state_id_from_params params[:ship_address_attributes]

          This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

          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

            Class has too many lines. [221/150]
            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 by rubocop

            This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

            Class has too many lines. [209/150]
            Open

              class StoreCredit < Spree::Base
                acts_as_paranoid
            
                VOID_ACTION       = 'void'.freeze
                CANCEL_ACTION     = 'cancel'.freeze

            This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

            File shipment_spec.rb has 654 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            require 'spec_helper'
            require 'benchmark'
            
            describe Spree::Shipment, type: :model do
              let(:order) do
            Severity: Major
            Found in core/spec/models/spree/shipment_spec.rb - About 1 day to fix

              File variant_spec.rb has 639 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              require 'spec_helper'
              
              describe Spree::Variant, type: :model do
                let!(:variant) { create(:variant) }
                let(:master_variant) { create(:master_variant) }
              Severity: Major
              Found in core/spec/models/spree/variant_spec.rb - About 1 day to fix

                File orders_controller_spec.rb has 638 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                require 'spec_helper'
                require 'spree/testing_support/bar_ability'
                
                module Spree
                  describe Api::V1::OrdersController, type: :controller do
                Severity: Major
                Found in api/spec/controllers/spree/api/v1/orders_controller_spec.rb - About 1 day to fix

                  Class has too many lines. [201/150]
                  Open

                    class InstallGenerator < Rails::Generators::Base
                      class_option :migrate, type: :boolean, default: true, banner: 'Run Spree migrations'
                      class_option :seed, type: :boolean, default: true, banner: 'load seed data (migrations must be run)'
                      class_option :sample, type: :boolean, default: true, banner: 'load sample data (migrations must be run)'
                      class_option :copy_views, type: :boolean, default: true, banner: 'copy frontend views from spree to your application for easy customization'

                  This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

                  File checkout_spec.rb has 637 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  require 'spec_helper'
                  require 'spree/testing_support/order_walkthrough'
                  
                  describe Spree::Order, type: :model do
                    let(:order) { Spree::Order.new }
                  Severity: Major
                  Found in core/spec/models/spree/order/checkout_spec.rb - About 1 day to fix
                    Severity
                    Category
                    Status
                    Source
                    Language