shadowban-eu/TwitterShadowBanV2

View on GitHub
src/js/console-log-viewer.js

Summary

Maintainability
F
1 wk
Test Coverage

Function ConsoleLogViewer has a Cognitive Complexity of 93 (exceeds 5 allowed). Consider refactoring.
Open

var ConsoleLogViewer = (function() {
  ConsoleLogViewer.ALIGNMENT = "top"; // top | bottom
  ConsoleLogViewer.IS_MINIMIZED = false; // true | false
  ConsoleLogViewer.LOG_ENABLED = true;
  ConsoleLogViewer.IS_CLOSED = false;
Severity: Minor
Found in src/js/console-log-viewer.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

Function ConsoleLogViewer has 260 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var ConsoleLogViewer = (function() {
  ConsoleLogViewer.ALIGNMENT = "top"; // top | bottom
  ConsoleLogViewer.IS_MINIMIZED = false; // true | false
  ConsoleLogViewer.LOG_ENABLED = true;
  ConsoleLogViewer.IS_CLOSED = false;
Severity: Major
Found in src/js/console-log-viewer.js - About 1 day to fix

    File console-log-viewer.js has 545 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /**
     * Displays logs and Javascript errors in an overlay on top of your site. Useful for mobile webdevelopment.
     *
     * <https://github.com/markknol/console-log-viewer>
     * @author Mark Knol <http://blog.stroep.nl>
    Severity: Major
    Found in src/js/console-log-viewer.js - About 1 day to fix

      Function addDivs has 68 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        ConsoleLogViewer.prototype.addDivs = function(self)
        {
          var self = self;
          var alignment = window.location.href.indexOf("console_at_bottom=true") > -1 || window.location.href.indexOf("console_at_bottom=1") > -1 ? "bottom-aligned" : "top-aligned";
          var scripts = window.document.getElementsByTagName('script');
      Severity: Major
      Found in src/js/console-log-viewer.js - About 2 hrs to fix

        Function request has 65 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          request: function(post) {
            var me = this;
            me.responseData = null;
            var r = this.req = js_Browser.createXMLHttpRequest();
            var onreadystatechange = function(_) {
        Severity: Major
        Found in src/js/console-log-viewer.js - About 2 hrs to fix

          Function __string_rec has 65 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          js_Boot.__string_rec = function(o,s) {
            if(o == null) return "null";
            if(s.length >= 5) return "<...>";
            var t = typeof(o);
            if(t == "function" && (o.__name__ || o.__ename__)) t = "object";
          Severity: Major
          Found in src/js/console-log-viewer.js - About 2 hrs to fix

            Function overwrite has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              ConsoleLogViewer.prototype.overwrite = function()
              {
                var self = this;
                // store original functions
                var original =
            Severity: Minor
            Found in src/js/console-log-viewer.js - About 1 hr to fix

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

              DebugSource.show = function(url,message) {
                var $window = window.open("","_blank");
                var http = new haxe_Http(url.split("#").shift());
                http.onData = function(data) {
                  var startLineNumber = Std.parseInt(url.split("#").pop().split("-").shift()) - 1;
              Severity: Minor
              Found in src/js/console-log-viewer.js - About 1 hr to fix

                Function onData has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  http.onData = function(data) {
                    var startLineNumber = Std.parseInt(url.split("#").pop().split("-").shift()) - 1;
                    var endLineNumber = Std.parseInt(url.split("#").pop().split("-").pop()) - 1;
                    var css = $window.document.createElement("style");
                    var stylesheet = "body{font:14px consolas,'courier new',monospaced;background:#FFF;}\npre{max-width:1000px;width:100%;white-space:pre-line;}\n.highlighted-line{background:yellow;display:inline-block;}\n.tab{padding-right:20px;}\n.keyword{color:blue;}\n.operator{color:lightgray;}\n.linenumber{display:inline-block;width:45px;margin-right:5px;background:darkgray;color:white;}\n.debug-error{display:block;background:red;color:white;}";
                Severity: Minor
                Found in src/js/console-log-viewer.js - About 1 hr to fix

                  Function onreadystatechange has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      var onreadystatechange = function(_) {
                        if(r.readyState != 4) return;
                        var s;
                        try {
                          s = r.status;
                  Severity: Minor
                  Found in src/js/console-log-viewer.js - About 1 hr to fix

                    Avoid deeply nested control flow statements.
                    Open

                              if(i != 2) str += "," + js_Boot.__string_rec(o[i],s); else str += js_Boot.__string_rec(o[i],s);
                    Severity: Major
                    Found in src/js/console-log-viewer.js - About 45 mins to fix

                      Avoid too many return statements within this function.
                      Open

                            return "???";
                      Severity: Major
                      Found in src/js/console-log-viewer.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                              if(s2 != "[object Object]") return s2;
                        Severity: Major
                        Found in src/js/console-log-viewer.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                              return str2;
                          Severity: Major
                          Found in src/js/console-log-viewer.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                  return str1;
                            Severity: Major
                            Found in src/js/console-log-viewer.js - About 30 mins to fix

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

                                  if (original.console.error) console.error = function()
                                  {
                                    self.log(self.flatten(Array.prototype.slice.call(arguments).join(",")),"log-error", true);
                                    original.console.error.apply(this, arguments);
                                  }
                              Severity: Major
                              Found in src/js/console-log-viewer.js and 4 other locations - About 2 hrs to fix
                              src/js/console-log-viewer.js on lines 135..139
                              src/js/console-log-viewer.js on lines 140..144
                              src/js/console-log-viewer.js on lines 145..149
                              src/js/console-log-viewer.js on lines 150..154

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

                              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 5 locations. Consider refactoring.
                              Open

                                  if (original.console.log) console.log = function()
                                  {
                                    self.log(self.flatten(Array.prototype.slice.call(arguments).join(",")),"log-normal", true);
                                    original.console.log.apply(this, arguments);
                                  }
                              Severity: Major
                              Found in src/js/console-log-viewer.js and 4 other locations - About 2 hrs to fix
                              src/js/console-log-viewer.js on lines 140..144
                              src/js/console-log-viewer.js on lines 145..149
                              src/js/console-log-viewer.js on lines 150..154
                              src/js/console-log-viewer.js on lines 155..159

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

                              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 5 locations. Consider refactoring.
                              Open

                                  if (original.console.debug) console.debug = function()
                                  {
                                    self.log(self.flatten(Array.prototype.slice.call(arguments).join(",")),"log-debug", true);
                                    original.console.debug.apply(this, arguments);
                                  }
                              Severity: Major
                              Found in src/js/console-log-viewer.js and 4 other locations - About 2 hrs to fix
                              src/js/console-log-viewer.js on lines 135..139
                              src/js/console-log-viewer.js on lines 145..149
                              src/js/console-log-viewer.js on lines 150..154
                              src/js/console-log-viewer.js on lines 155..159

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

                              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 5 locations. Consider refactoring.
                              Open

                                  if (original.console.warn) console.warn = function()
                                  {
                                    self.log(self.flatten(Array.prototype.slice.call(arguments).join(",")),"log-warn", true);
                                    original.console.warn.apply(this, arguments);
                                  }
                              Severity: Major
                              Found in src/js/console-log-viewer.js and 4 other locations - About 2 hrs to fix
                              src/js/console-log-viewer.js on lines 135..139
                              src/js/console-log-viewer.js on lines 140..144
                              src/js/console-log-viewer.js on lines 145..149
                              src/js/console-log-viewer.js on lines 155..159

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

                              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 5 locations. Consider refactoring.
                              Open

                                  if (original.console.info) console.info = function()
                                  {
                                    self.log(self.flatten(Array.prototype.slice.call(arguments).join(",")),"log-info", true);
                                    original.console.info.apply(this, arguments);
                                  }
                              Severity: Major
                              Found in src/js/console-log-viewer.js and 4 other locations - About 2 hrs to fix
                              src/js/console-log-viewer.js on lines 135..139
                              src/js/console-log-viewer.js on lines 140..144
                              src/js/console-log-viewer.js on lines 150..154
                              src/js/console-log-viewer.js on lines 155..159

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

                              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

                                  document.getElementById("debug_console_pause_button").addEventListener("click", function(e) {
                                    ConsoleLogViewer.LOG_ENABLED = !ConsoleLogViewer.LOG_ENABLED;
                                    self.setLogEnabled(ConsoleLogViewer.LOG_ENABLED);
                                    e.preventDefault();
                                  }, false);
                              Severity: Major
                              Found in src/js/console-log-viewer.js and 1 other location - About 1 hr to fix
                              src/js/console-log-viewer.js on lines 224..228

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

                              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

                                  document.getElementById("debug_console_minimize_button").addEventListener("click", function(e) {
                                    ConsoleLogViewer.IS_MINIMIZED = !ConsoleLogViewer.IS_MINIMIZED;
                                    self.setMinimized(ConsoleLogViewer.IS_MINIMIZED);
                                    e.preventDefault();
                                  }, false);
                              Severity: Major
                              Found in src/js/console-log-viewer.js and 1 other location - About 1 hr to fix
                              src/js/console-log-viewer.js on lines 236..240

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

                              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

                                  var startLineNumber = Std.parseInt(url.split("#").pop().split("-").shift()) - 1;
                              Severity: Minor
                              Found in src/js/console-log-viewer.js and 1 other location - About 40 mins to fix
                              src/js/console-log-viewer.js on lines 320..320

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

                              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

                                  var endLineNumber = Std.parseInt(url.split("#").pop().split("-").pop()) - 1;
                              Severity: Minor
                              Found in src/js/console-log-viewer.js and 1 other location - About 40 mins to fix
                              src/js/console-log-viewer.js on lines 319..319

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

                              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

                                  data = data.split("<").join("&lt;").split(">").join("&gt;").split("\"").join("&quot;");
                              Severity: Minor
                              Found in src/js/console-log-viewer.js and 1 other location - About 40 mins to fix
                              src/js/console-log-viewer.js on lines 84..84

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

                              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

                                  return value.split("<").join("&lt;").split(">").join("&gt;").split("\"").join("&quot;");
                              Severity: Minor
                              Found in src/js/console-log-viewer.js and 1 other location - About 40 mins to fix
                              src/js/console-log-viewer.js on lines 327..327

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

                              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