Plate-Project/plate

View on GitHub
plate/static/js/jquery.tocify.js

Summary

Maintainability
F
3 days
Test Coverage

File jquery.tocify.js has 398 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* jquery Tocify - v1.9.0 - 2013-10-01
* http://www.gregfranko.com/jquery.tocify.js/
* Copyright (c) 2013 Greg Franko; Licensed MIT */

// Immediately-Invoked Function Expression (IIFE) [Ben Alman Blog Post](http://benalman.com/news/2010/11/immediately-invoked-function-expression/) that calls another IIFE that contains all of the plugin logic.  I used this pattern so that anyone viewing this code would not have to scroll to the bottom of the page to view the local parameters that were passed to the main IIFE.
Severity: Minor
Found in plate/static/js/jquery.tocify.js - About 5 hrs to fix

    Function _setEventHandlers has 88 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            _setEventHandlers: function() {
    
                // _Local variables_
    
                // Stores the plugin context in the self variable
    Severity: Major
    Found in plate/static/js/jquery.tocify.js - About 3 hrs to fix

      Function _generateToc has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              _generateToc: function() {
      
                  // _Local variables_
      
                  // Stores the plugin context in the self variable
      Severity: Minor
      Found in plate/static/js/jquery.tocify.js - About 1 hr to fix

        Function show has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                show: function(elem, scroll) {
        
                    // Stores the plugin context in the `self` variable
                    var self = this,
                        element = elem;
        Severity: Minor
        Found in plate/static/js/jquery.tocify.js - About 1 hr to fix

          Avoid deeply nested control flow statements.
          Open

                                              if(!lastElem.length) return;
          Severity: Major
          Found in plate/static/js/jquery.tocify.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                                if(self.extendPageScroll) {
            
                                                    currentElem = self.element.find('li.active');
            
                                                    self._scrollTo($('div[data-unique="' + currentElem.attr("data-unique") + '"]'));
            Severity: Major
            Found in plate/static/js/jquery.tocify.js - About 45 mins to fix

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

                          switch (self.options.hideEffect) {
              
                              // Uses `no effect`
                              case "none":
              
              
              Severity: Major
              Found in plate/static/js/jquery.tocify.js and 1 other location - About 4 hrs to fix
              plate/static/js/jquery.tocify.js on lines 742..779

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

              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

                              switch (self.options.showEffect) {
              
                                  //Uses `no effect`
                                  case "none":
              
              
              Severity: Major
              Found in plate/static/js/jquery.tocify.js and 1 other location - About 4 hrs to fix
              plate/static/js/jquery.tocify.js on lines 813..850

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

              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 {
              
                                      // Loops through all of the subheader elements
                                      $(this).find(self.options.selectors).each(function() {
              
              
              Severity: Major
              Found in plate/static/js/jquery.tocify.js and 1 other location - About 2 hrs to fix
              plate/static/js/jquery.tocify.js on lines 266..280

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

              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($(this).find(self.options.selectors).length === 0) {
              
                                      // Loops through all of the subheader elements
                                      $(this).filter(self.options.selectors).each(function() {
              
              
              Severity: Major
              Found in plate/static/js/jquery.tocify.js and 1 other location - About 2 hrs to fix
              plate/static/js/jquery.tocify.js on lines 283..297

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

              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