drhenner/ror_ecommerce

View on GitHub

Showing 346 of 346 total issues

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

    if params[:address].present?
      @shopping_address = current_user.addresses.new(allowed_params)
      @shopping_address.default = true          if current_user.default_shipping_address.nil?
      @shopping_address.billing_default = true  if current_user.default_billing_address.nil?
      @shopping_address.save
Severity: Minor
Found in app/controllers/shopping/addresses_controller.rb and 1 other location - About 45 mins to fix
app/controllers/shopping/billing_addresses_controller.rb on lines 25..33

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 41.

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

Avoid deeply nested control flow statements.
Open

                if ($customRadio.length === 0) {
                  $customRadio = $associatedElement.add(this).siblings('span.custom.radio').first();
                }
Severity: Major
Found in app/assets/javascripts/foundation/foundation.forms.js - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                if (this.settings.timer > 0) {
    
                  this.settings.$next_tip
                    .fadeIn(this.settings.tipAnimationFadeSpeed)
                    .show();
    Severity: Major
    Found in app/assets/javascripts/foundation/foundation.joyride.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                        if (!region.hasClass(self.settings.active_class))
                          region.addClass(self.settings.active_class);
      Severity: Major
      Found in app/assets/javascripts/foundation/foundation.section.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                      if (this.result_highlight && result_id === this.result_highlight.attr('id')) {
                        this.result_clear_highlight();
                      }
        Severity: Major
        Found in app/assets/javascripts/chosen/chosen.jquery.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if (placeholder !== elem.getAttribute(ATTR_CURRENT_VAL) || (elem.type === "password" && !elem.getAttribute(ATTR_INPUT_TYPE))) {
          
                                      // Attempt to change the type of password inputs (fails in IE < 9)
                                      if (elem.type === "password" && !elem.getAttribute(ATTR_INPUT_TYPE) && Utils.changeType(elem, "text")) {
                                          elem.setAttribute(ATTR_INPUT_TYPE, "password");
          Severity: Major
          Found in app/assets/javascripts/foundation/foundation.placeholder.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                      if ( typeof elem.getElementsByTagName !== "undefined" ) {
                        // handleScript alters the DOM, so use jQuery.merge to ensure snapshot iteration
                        jsTags = jQuery.grep( jQuery.merge( [], elem.getElementsByTagName("script") ), handleScript );
            
                        // Splice the scripts into ret after their former ancestor and advance our index beyond them
            Severity: Major
            Found in app/assets/javascripts/jquery/jquery-migrate-1.1.1.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                            if (parts.length) {
                              for (_j = 0, _len2 = parts.length; _j < _len2; _j++) {
                                part = parts[_j];
                                if (regex.test(part)) {
                                  found = true;
              Severity: Major
              Found in app/assets/javascripts/chosen/chosen.jquery.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if (!elem.getAttribute(ATTR_EVENTS_BOUND)) {
                                            newElement(elem);
                                        }
                Severity: Major
                Found in app/assets/javascripts/foundation/foundation.placeholder.js - About 45 mins to fix

                  Function add has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                    function add(element, events, fn, selector, getDelegate, capture){
                  Severity: Minor
                  Found in app/assets/javascripts/zepto.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                if ($(klass).hasClass('fixed')) {
                                  $(klass).removeClass('fixed');
                                  $('body').removeClass('f-topbar-fixed');
                                }
                    Severity: Major
                    Found in app/assets/javascripts/foundation/foundation.topbar.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                    if (searchText.length) {
                                      startpos = option.html.search(zregex);
                                      text = option.html.substr(0, startpos + searchText.length) + '</em>' + option.html.substr(startpos + searchText.length);
                                      text = text.substr(0, startpos) + '<em>' + text.substr(startpos);
                                    } else {
                      Severity: Major
                      Found in app/assets/javascripts/chosen/chosen.jquery.js - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                      if (option.group_array_index != null) {
                                        $("#" + this.results_data[option.group_array_index].dom_id).css('display', 'list-item');
                                      }
                        Severity: Major
                        Found in app/assets/javascripts/chosen/chosen.jquery.js - About 45 mins to fix

                          Function init has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              init : function (scope, libraries, method, options, response, /* internal */ nc) {
                          Severity: Minor
                          Found in app/assets/javascripts/foundation_init/foundation.js - About 45 mins to fix

                            Method update_tax_rates has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def update_tax_rates
                                if saved_change_to_attribute?(:ship_address_id)
                                  # set_beginning_values
                                  tax_time = completed_at? ? completed_at : Time.zone.now
                                  order_items.each do |item|
                            Severity: Minor
                            Found in app/models/order.rb - About 45 mins 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 create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def create
                                if params[:address].present?
                                  @shopping_address = current_user.addresses.new(allowed_params)
                                  @shopping_address.default = true          if current_user.default_shipping_address.nil?
                                  @shopping_address.billing_default = true  if current_user.default_billing_address.nil?
                            Severity: Minor
                            Found in app/controllers/shopping/addresses_controller.rb - About 45 mins 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

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

                                            a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
                            Severity: Minor
                            Found in app/assets/javascripts/jqwizard/jquery.form.js and 1 other location - About 45 mins to fix
                            app/assets/javascripts/jqwizard/jquery.form.js on lines 472..472

                            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 50.

                            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

                            Method create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def create
                                if params[:address].present?
                                  @billing_address = checkout_user.addresses.new(allowed_params)
                                  @billing_address.default = true          if checkout_user.default_billing_address.nil?
                                  @billing_address.billing_default = true  if checkout_user.default_billing_address.nil?
                            Severity: Minor
                            Found in app/controllers/admin/shopping/checkout/billing_addresses_controller.rb - About 45 mins 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 create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def create
                                if params[:address].present?
                                  @shipping_address = checkout_user.addresses.new(allowed_params)
                                  @shipping_address.default = true          if checkout_user.default_shipping_address.nil?
                                  @shipping_address.billing_default = true  if checkout_user.default_billing_address.nil?
                            Severity: Minor
                            Found in app/controllers/admin/shopping/checkout/shipping_addresses_controller.rb - About 45 mins 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 create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def create
                                if params[:address].present?
                                  @shopping_address = current_user.addresses.new(allowed_params)
                                  @shopping_address.default = true          if current_user.default_shipping_address.nil?
                                  @shopping_address.billing_default = true  if current_user.default_billing_address.nil?
                            Severity: Minor
                            Found in app/controllers/shopping/billing_addresses_controller.rb - About 45 mins 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

                            Severity
                            Category
                            Status
                            Source
                            Language