DamageStudios/rims

View on GitHub
app/assets/javascripts/application.js

Summary

Maintainability
F
3 wks
Test Coverage

Function makeSortable has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
Open

  makeSortable: function(table) {
    if (table.getElementsByTagName('thead').length == 0) {
      // table doesn't have a tHead. Since it should have, create one and
      // put the first table row in it.
      the = document.createElement('thead');
Severity: Minor
Found in app/assets/javascripts/application.js - About 1 day 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 application.js has 338 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
Severity: Minor
Found in app/assets/javascripts/application.js - About 4 hrs to fix

    Function makeSortable has 89 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      makeSortable: function(table) {
        if (table.getElementsByTagName('thead').length == 0) {
          // table doesn't have a tHead. Since it should have, create one and
          // put the first table row in it.
          the = document.createElement('thead');
    Severity: Major
    Found in app/assets/javascripts/application.js - About 3 hrs to fix

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

                dean_addEvent(headrow[i],"click", sorttable.innerSortFunction = function(e) {
      
                  if (this.className.search(/\bsorttable_sorted\b/) != -1) {
                    // if we're already sorted by this column, just
                    // reverse the table, which is quicker
      Severity: Minor
      Found in app/assets/javascripts/application.js - About 2 hrs to fix

        Function guessType has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            guessType: function(table, column) {
              // guess the type of a column based on its first non-blank row
              sortfn = sorttable.sort_alpha;
              for (var i=0; i<table.tBodies[0].rows.length; i++) {
                text = sorttable.getInnerText(table.tBodies[0].rows[i].cells[column]);
        Severity: Minor
        Found in app/assets/javascripts/application.js - About 1 hr 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 getInnerText has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            getInnerText: function(node) {
              // gets the text we want to use for sorting for a cell.
              // strips leading and trailing whitespace.
              // this is *not* a generic getInnerText function; it's special to sorttable.
              // for example, you can override the cell text with a customkey attribute.
        Severity: Minor
        Found in app/assets/javascripts/application.js - About 1 hr 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 shaker_sort has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

                      shaker_sort: function(list, comp_func) {
                        // A stable sort function to allow multi-level sorting of data
                        // see: http://en.wikipedia.org/wiki/Cocktail_sort
                        // thanks to Joseph Nahmias
                        var b = 0;
        Severity: Minor
        Found in app/assets/javascripts/application.js - About 1 hr 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 getInnerText has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            getInnerText: function(node) {
              // gets the text we want to use for sorting for a cell.
              // strips leading and trailing whitespace.
              // this is *not* a generic getInnerText function; it's special to sorttable.
              // for example, you can override the cell text with a customkey attribute.
        Severity: Minor
        Found in app/assets/javascripts/application.js - About 1 hr to fix

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

                  function dean_addEvent(element, type, handler) {
                    if (element.addEventListener) {
                      element.addEventListener(type, handler, false);
                    } else {
                      // assign each event handler a unique ID
          Severity: Minor
          Found in app/assets/javascripts/application.js - About 1 hr 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

          Avoid too many return statements within this function.
          Open

                  return node.text.replace(/^\s+|\s+$/g, '');
          Severity: Major
          Found in app/assets/javascripts/application.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                          return node.value.replace(/^\s+|\s+$/g, '');
            Severity: Major
            Found in app/assets/javascripts/application.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                                return innerText.replace(/^\s+|\s+$/g, '');
              Severity: Major
              Found in app/assets/javascripts/application.js - About 30 mins to fix

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

                              sort_mmdd: function(a,b) {
                                mtch = a[0].match(sorttable.DATE_RE);
                                y = mtch[3]; d = mtch[2]; m = mtch[1];
                                if (m.length == 1) m = '0'+m;
                                if (d.length == 1) d = '0'+d;
                Severity: Minor
                Found in app/assets/javascripts/application.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

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

                              sort_ddmm: function(a,b) {
                                mtch = a[0].match(sorttable.DATE_RE);
                                y = mtch[3]; m = mtch[2]; d = mtch[1];
                                if (m.length == 1) m = '0'+m;
                                if (d.length == 1) d = '0'+d;
                Severity: Minor
                Found in app/assets/javascripts/application.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

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

                        var forEach = function(object, block, context) {
                          if (object) {
                            var resolve = Object; // default
                            if (object instanceof Function) {
                              // functions have a "length" property
                Severity: Minor
                Found in app/assets/javascripts/application.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

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

                sorttable = {
                  init: function() {
                    // quit if this function has already been called
                    if (arguments.callee.done) return;
                    // flag this function so we don't do the same thing twice
                Severity: Major
                Found in app/assets/javascripts/application.js and 1 other location - About 2 wks to fix
                public/assets/application-404f4a61b35c93d3441d4475969d79cc4182aff2126750b4beaab13f73340f19.js on lines 14683..14996

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

                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

                        function dean_addEvent(element, type, handler) {
                          if (element.addEventListener) {
                            element.addEventListener(type, handler, false);
                          } else {
                            // assign each event handler a unique ID
                Severity: Major
                Found in app/assets/javascripts/application.js and 1 other location - About 1 day to fix
                public/assets/application-404f4a61b35c93d3441d4475969d79cc4182aff2126750b4beaab13f73340f19.js on lines 15038..15060

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

                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

                        var forEach = function(object, block, context) {
                          if (object) {
                            var resolve = Object; // default
                            if (object instanceof Function) {
                              // functions have a "length" property
                Severity: Major
                Found in app/assets/javascripts/application.js and 1 other location - About 5 hrs to fix
                public/assets/application-404f4a61b35c93d3441d4475969d79cc4182aff2126750b4beaab13f73340f19.js on lines 15137..15156

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

                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

                        function handleEvent(event) {
                          var returnValue = true;
                          // grab the event object (IE uses a global event object)
                          event = event || fixEvent(((this.ownerDocument || this.document || this).parentWindow || window).event);
                          // get a reference to the hash table of event handlers
                Severity: Major
                Found in app/assets/javascripts/application.js and 1 other location - About 5 hrs to fix
                public/assets/application-404f4a61b35c93d3441d4475969d79cc4182aff2126750b4beaab13f73340f19.js on lines 15075..15089

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

                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

                        function removeEvent(element, type, handler) {
                          if (element.removeEventListener) {
                            element.removeEventListener(type, handler, false);
                          } else {
                            // delete the event handler from the hash table
                Severity: Major
                Found in app/assets/javascripts/application.js and 1 other location - About 2 hrs to fix
                public/assets/application-404f4a61b35c93d3441d4475969d79cc4182aff2126750b4beaab13f73340f19.js on lines 15064..15073

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

                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 (!Array.forEach) { // mozilla already supports this
                          Array.forEach = function(array, block, context) {
                            for (var i = 0; i < array.length; i++) {
                              block.call(context, array[i], i, array);
                            }
                Severity: Major
                Found in app/assets/javascripts/application.js and 1 other location - About 2 hrs to fix
                public/assets/application-404f4a61b35c93d3441d4475969d79cc4182aff2126750b4beaab13f73340f19.js on lines 15112..15118

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

                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

                        Function.prototype.forEach = function(object, block, context) {
                          for (var key in object) {
                            if (typeof this.prototype[key] == "undefined") {
                              block.call(context, object[key], key, object);
                            }
                Severity: Major
                Found in app/assets/javascripts/application.js and 1 other location - About 2 hrs to fix
                public/assets/application-404f4a61b35c93d3441d4475969d79cc4182aff2126750b4beaab13f73340f19.js on lines 15121..15127

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

                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 (/WebKit/i.test(navigator.userAgent)) { // sniff
                          var _timer = setInterval(function() {
                            if (/loaded|complete/.test(document.readyState)) {
                              sorttable.init(); // call the onload handler
                            }
                Severity: Major
                Found in app/assets/javascripts/application.js and 1 other location - About 2 hrs to fix
                public/assets/application-404f4a61b35c93d3441d4475969d79cc4182aff2126750b4beaab13f73340f19.js on lines 15022..15028

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

                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

                        String.forEach = function(string, block, context) {
                          Array.forEach(string.split(""), function(chr, index) {
                            block.call(context, chr, index, string);
                          });
                        };
                Severity: Major
                Found in app/assets/javascripts/application.js and 1 other location - About 1 hr to fix
                public/assets/application-404f4a61b35c93d3441d4475969d79cc4182aff2126750b4beaab13f73340f19.js on lines 15130..15134

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

                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