drhenner/ror_ecommerce

View on GitHub
app/assets/javascripts/foundation/foundation.section.js

Summary

Maintainability
D
2 days
Test Coverage

Function resize has 107 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    resize: function(sections, ensure_has_active_region) {

      var self = Foundation.libs.section,
          section_container = $(self.settings.section_selector),
          is_small_window = self.small(section_container),
Severity: Major
Found in app/assets/javascripts/foundation/foundation.section.js - About 4 hrs to fix

    File foundation.section.js has 322 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*jslint unparam: true, browser: true, indent: 2 */
    
    ;
    (function($, window, document) {
      'use strict';
    Severity: Minor
    Found in app/assets/javascripts/foundation/foundation.section.js - About 3 hrs to fix

      Function set_active_from_hash has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          set_active_from_hash: function() {
            var self = Foundation.libs.section,
                hash = window.location.hash.substring(1),
                sections = $(self.settings.section_selector);
      
      
      Severity: Minor
      Found in app/assets/javascripts/foundation/foundation.section.js - About 2 hrs to fix

        Function events has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            events: function() {
              var self = this;
        
              //combine titles selector from settings for click event binding
              var click_title_selectors = [],
        Severity: Minor
        Found in app/assets/javascripts/foundation/foundation.section.js - About 1 hr to fix

          Consider simplifying this complex logical expression.
          Open

                } else if (region.hasClass(self.settings.active_class) && self.is_accordion(section) || !settings.one_up && (self.small(section) || self.is_vertical_nav(section) || self.is_horizontal_nav(section) || self.is_accordion(section))) {
                  region.removeClass(self.settings.active_class);
                  region.trigger('closed.fndtn.section');
                }
          Severity: Major
          Found in app/assets/javascripts/foundation/foundation.section.js - About 1 hr 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 too many return statements within this function.
              Open

                    return $(this.scope).width() < settings.small_breakpoint;
              Severity: Major
              Found in app/assets/javascripts/foundation/foundation.section.js - About 30 mins to fix

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

                            regions.each(function () {
                              var region = $(this);
                
                              region.css("margin-top", "-" + (first1 ? section : region.children(self.settings.title_selector)).css("border-top-width"));
                              first1 = false;
                Severity: Major
                Found in app/assets/javascripts/foundation/foundation.section.js and 1 other location - About 2 hrs to fix
                app/assets/javascripts/foundation/foundation.section.js on lines 234..239

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

                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

                            regions.each(function() {
                              var region = $(this);
                
                              region.css("margin-left", "-" + (first ? section : region.children(self.settings.title_selector)).css("border-left-width"));
                              first = false;
                Severity: Major
                Found in app/assets/javascripts/foundation/foundation.section.js and 1 other location - About 2 hrs to fix
                app/assets/javascripts/foundation/foundation.section.js on lines 276..281

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

                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

                            if (!settings.deep_linking && (settings.one_up || !self.is_horizontal_nav(section) &&
                              !self.is_vertical_nav(section) && !self.is_accordion(section))) {
                Severity: Minor
                Found in app/assets/javascripts/foundation/foundation.section.js and 1 other location - About 40 mins to fix
                app/assets/javascripts/foundation/foundation.section.js on lines 380..381

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

                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

                            titles.each(function() {
                              titles_max_width = Math.max(titles_max_width, self.outerWidth($(this)));
                            });
                Severity: Minor
                Found in app/assets/javascripts/foundation/foundation.section.js and 1 other location - About 40 mins to fix
                app/assets/javascripts/foundation/foundation.section.js on lines 230..232

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

                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

                            if (!selected && (settings.one_up || !self.is_horizontal_nav(section) &&
                             !self.is_vertical_nav(section) && !self.is_accordion(section)))
                Severity: Minor
                Found in app/assets/javascripts/foundation/foundation.section.js and 1 other location - About 40 mins to fix
                app/assets/javascripts/foundation/foundation.section.js on lines 184..185

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

                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

                            titles.each(function() {
                              titles_max_height = Math.max(titles_max_height, self.outerHeight($(this)));
                            });
                Severity: Minor
                Found in app/assets/javascripts/foundation/foundation.section.js and 1 other location - About 40 mins to fix
                app/assets/javascripts/foundation/foundation.section.js on lines 272..274

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

                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

                There are no issues that match your filters.

                Category
                Status