concord-consortium/rigse

View on GitHub
rails/app/assets/javascripts/active_scaffold/default/dhtml_history.js

Summary

Maintainability
D
2 days
Test Coverage

File dhtml_history.js has 474 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
Copyright (c) 2007 Brian Dillard and Brad Neuberg:
Brian Dillard | Project Lead | bdillard@pathf.com | http://blogs.pathf.com/agileajax/
Brad Neuberg | Original Project Creator | http://codinginparadise.org

Severity: Minor
Found in rails/app/assets/javascripts/active_scaffold/default/dhtml_history.js - About 7 hrs to fix

    Function create has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

           create: function(options) {
                   
                   /*
                           options - object to store initialization parameters
                           options.blankURL - string to override the default location of blank.html. Must end in "?"
    Severity: Minor
    Found in rails/app/assets/javascripts/active_scaffold/default/dhtml_history.js - 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

    Function create has 66 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

           create: function(options) {
                   
                   /*
                           options - object to store initialization parameters
                           options.blankURL - string to override the default location of blank.html. Must end in "?"
    Severity: Major
    Found in rails/app/assets/javascripts/active_scaffold/default/dhtml_history.js - About 2 hrs to fix

      dhtmlHistory has 21 functions (exceeds 20 allowed). Consider refactoring.
      Open

      window.dhtmlHistory = {
             
             /*Public: User-agent booleans*/
             isIE: false,
             isOpera: false,
      Severity: Minor
      Found in rails/app/assets/javascripts/active_scaffold/default/dhtml_history.js - About 2 hrs to fix

        Function add has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

               add: function(newLocation, historyData) {
                       
                       var that = this;
                       
                       /*Escape the location and remove any leading hash symbols*/

          Function add has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

                 add: function(newLocation, historyData) {
                         
                         var that = this;
                         
                         /*Escape the location and remove any leading hash symbols*/

          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

          Function setup has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                 setup: function(options) {
                         
                         /*
                                 options - object to store initialization parameters - passed in from dhtmlHistory or directly into historyStorage
                                 options.debugMode - boolean that causes hidden form fields to be shown for development purposes.

          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

          Function changeTitle has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                 changeTitle: function(historyData) {
                         var winTitle = (historyData && historyData.newTitle
                                 /*Plug the new title into the pattern*/
                                 ? this.baseTitle.replace('@@@', historyData.newTitle)
                                 /*Otherwise, if there is no new title, use the original document title. This is useful when some
          Severity: Minor
          Found in rails/app/assets/javascripts/active_scaffold/default/dhtml_history.js - About 35 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

          Function removeHash has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                 removeHash: function(hashValue) {
                         var r;
                         if (hashValue === null || hashValue === undefined) {
                                 r = null;
                         }
          Severity: Minor
          Found in rails/app/assets/javascripts/active_scaffold/default/dhtml_history.js - About 25 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

                         if (hash.length == 1 && hash.charAt(0) == "?") {
                                 hash = "";
                         }
                         else if (hash.length >= 2 && hash.charAt(0) == "?") {
                                 hash = hash.substring(1);
          rails/app/assets/javascripts/active_scaffold/default/dhtml_history.js on lines 603..608

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

          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

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

                         if (hash.length == 1 && hash.charAt(0) == "?") {
                                 hash = "";
                         }
                         else if (hash.length >= 2 && hash.charAt(0) == "?") {
                                 hash = hash.substring(1);
          rails/app/assets/javascripts/active_scaffold/default/dhtml_history.js on lines 563..568

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

          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