vegantech/sims

View on GitHub
app/assets/javascripts/ie-console.js

Summary

Maintainability
F
3 days
Test Coverage

Function formatResult has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

    formatResult: function(result) {
        var type = IEConsole.getType(result);
        try {
            // DOM Element
            if (type == 'DOMElement') {
Severity: Minor
Found in app/assets/javascripts/ie-console.js - About 4 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

File ie-console.js has 279 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * Simple Javascript console for IE
 *
 * Inspired by Firebug for Firefox
 *
Severity: Minor
Found in app/assets/javascripts/ie-console.js - About 2 hrs to fix

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

    var IEConsole = {
        HEIGHT: 120,
        INPUT_HEIGHT: 25,
        block: false,
        open: false,
    Severity: Minor
    Found in app/assets/javascripts/ie-console.js - About 2 hrs to fix

      Function formatResult has 53 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          formatResult: function(result) {
              var type = IEConsole.getType(result);
              try {
                  // DOM Element
                  if (type == 'DOMElement') {
      Severity: Major
      Found in app/assets/javascripts/ie-console.js - About 2 hrs to fix

        Function onload has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

        window.onload = function(evt) {
            if (ieConsoleSavedOnLoad) ieConsoleSavedOnLoad(evt);
            if (typeof console == "undefined") console = {};
            if (typeof console.log == "undefined") {
                console.log = function(msg) {
        Severity: Minor
        Found in app/assets/javascripts/ie-console.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 getType has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            getType: function(value) {
                var self = IEConsole;
                var type = typeof value;
                try {
                    if (type == "undefined") {
        Severity: Minor
        Found in app/assets/javascripts/ie-console.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 getType has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            getType: function(value) {
                var self = IEConsole;
                var type = typeof value;
                try {
                    if (type == "undefined") {
        Severity: Minor
        Found in app/assets/javascripts/ie-console.js - About 1 hr to fix

          Avoid deeply nested control flow statements.
          Open

                                  if (i > 0) out += ', ';
          Severity: Major
          Found in app/assets/javascripts/ie-console.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if (i > 0) out += ', ';
            Severity: Major
            Found in app/assets/javascripts/ie-console.js - About 45 mins to fix

              Avoid too many return statements within this function.
              Open

                                  return "DOMNodeList: [" + out + ']';
              Severity: Major
              Found in app/assets/javascripts/ie-console.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                            return "unknown";
                Severity: Major
                Found in app/assets/javascripts/ie-console.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                                      return "DOMElement";
                  Severity: Major
                  Found in app/assets/javascripts/ie-console.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                        return "DOMNodeList";
                    Severity: Major
                    Found in app/assets/javascripts/ie-console.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                      return '"' + result.replace('"', '\\"')
                                                         .replace("\n", '\\n')
                                                         .replace("\r", '\\r')
                                             + '"';
                      Severity: Major
                      Found in app/assets/javascripts/ie-console.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                        return 'undefined';
                        Severity: Major
                        Found in app/assets/javascripts/ie-console.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                          return "unknown";
                          Severity: Major
                          Found in app/assets/javascripts/ie-console.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                            return "Array(length: " + result.length + ")";
                            Severity: Major
                            Found in app/assets/javascripts/ie-console.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                              return 'function() {}';
                              Severity: Major
                              Found in app/assets/javascripts/ie-console.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                            return "Failed to format result: " + e.message;
                                Severity: Major
                                Found in app/assets/javascripts/ie-console.js - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                                      return "Array";
                                  Severity: Major
                                  Found in app/assets/javascripts/ie-console.js - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                                        return "object";
                                    Severity: Major
                                    Found in app/assets/javascripts/ie-console.js - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                                      return "" + result;
                                      Severity: Major
                                      Found in app/assets/javascripts/ie-console.js - About 30 mins to fix

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

                                            createPromptAndInput: function() {
                                                var container = document.createElement("div");
                                                container.innerHTML = "<table style=\"width: 100%\" cellspacing=\"0\" cellpadding=\"0\"><tr>" +
                                                    "<td width=\"25\" style=\"padding-top: 10px;\">&gt;&gt;&gt;</td>" +
                                                    "<td><input type=\"text\" /></td>" +
                                        Severity: Minor
                                        Found in app/assets/javascripts/ie-console.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 (!IEConsole.block) {
                                                    IEConsole.block = IEConsole.createContainer();
                                                    document.body.insertBefore(IEConsole.block, document.body.childNodes[0]);
                                                    //IEConsole.inputElement.focus();
                                                }
                                        Severity: Major
                                        Found in app/assets/javascripts/ie-console.js and 1 other location - About 1 hr to fix
                                        app/assets/javascripts/ie-console.js on lines 261..265

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

                                        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 (!IEConsole.block) {
                                                    IEConsole.block = IEConsole.createContainer();
                                                    document.body.insertBefore(IEConsole.block, document.body.childNodes[0]);
                                                    //IEConsole.inputElement.focus();
                                                }
                                        Severity: Major
                                        Found in app/assets/javascripts/ie-console.js and 1 other location - About 1 hr to fix
                                        app/assets/javascripts/ie-console.js on lines 45..49

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

                                        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