Showing 299 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

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    if (new_shipment != undefined) {
                      // TRANSFER TO A NEW LOCATION
                      $.ajax({
                        type: "POST",
                        async: false,
                Severity: Major
                Found in backend/app/assets/javascripts/spree/backend/shipments.js and 1 other location - About 5 hrs to fix
                backend/app/assets/javascripts/spree/backend/shipments.js on lines 307..325

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 144.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    } else {
                        // TRANSFER TO AN EXISTING SHIPMENT
                        $.ajax({
                            type: "POST",
                            async: false,
                Severity: Major
                Found in backend/app/assets/javascripts/spree/backend/shipments.js and 1 other location - About 5 hrs to fix
                backend/app/assets/javascripts/spree/backend/shipments.js on lines 289..307

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 144.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                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

                      Similar blocks of code found in 2 locations. Consider refactoring.
                      Open

                        $('#add_variant_id').change(function(){
                          var variant_id = $(this).val();
                      
                          var variant = _.find(window.variants, function(variant){
                            return variant.id == variant_id
                      Severity: Major
                      Found in backend/app/assets/javascripts/spree/backend/shipments.js and 1 other location - About 4 hrs to fix
                      backend/app/assets/javascripts/spree/backend/line_items_on_order_edit.js on lines 6..16

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 128.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Similar blocks of code found in 2 locations. Consider refactoring.
                      Open

                          $('#add_line_item_variant_id').change(function(){
                              var variant_id = $(this).val();
                      
                              var variant = _.find(window.variants, function(variant){
                                  return variant.id == variant_id
                      backend/app/assets/javascripts/spree/backend/shipments.js on lines 6..16

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 128.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      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
                              Severity
                              Category
                              Status
                              Source