MiniProfiler/rack-mini-profiler

View on GitHub
lib/html/pretty-print.js

Summary

Maintainability
F
2 mos
Test Coverage

File pretty-print.js has 683 lines of code (exceeds 250 allowed). Consider refactoring.
Open

if (typeof prettyPrint === "undefined") {
  // prettify.js
  // http://code.google.com/p/google-code-prettify/
  // prettier-ignore
  window.PR_SHOULD_USE_CONTINUATION = true;
Severity: Major
Found in lib/html/pretty-print.js - About 1 day to fix

    Function O has 133 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function O(b) {
          function f(c) {
            if (c.charAt(0) !== "\\") return c.charCodeAt(0);
    
            switch (c.charAt(1)) {
    Severity: Major
    Found in lib/html/pretty-print.js - About 5 hrs to fix

      Consider simplifying this complex logical expression.
      Open

      if (typeof prettyPrint === "undefined") {
        // prettify.js
        // http://code.google.com/p/google-code-prettify/
        // prettier-ignore
        window.PR_SHOULD_USE_CONTINUATION = true;
      Severity: Critical
      Found in lib/html/pretty-print.js - About 4 hrs to fix

        Function prettyPrint has 77 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            window.prettyPrint = function (b) {
              function f() {
                for (var t = window.PR_SHOULD_USE_CONTINUATION ? j.now() + 250 : Infinity; q < o.length && j.now() < t; q++) {
                  var p = o[q];
        
        
        Severity: Major
        Found in lib/html/pretty-print.js - About 3 hrs to fix

          Function U has 71 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function U(b) {
                var f = b.f,
                    i = b.e;
                b.a = f;
          
          
          Severity: Major
          Found in lib/html/pretty-print.js - About 2 hrs to fix

            Function $ has 67 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function $(b) {
                  function f(D) {
                    if (D > r) {
                      if (j && j !== q) {
                        n.push("</span>");
            Severity: Major
            Found in lib/html/pretty-print.js - About 2 hrs to fix

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

                  function B(b, f) {
                    var i = {},
                        o;
              
                    (function () {
              Severity: Major
              Found in lib/html/pretty-print.js - About 2 hrs to fix

                Function f has 60 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      function f() {
                        for (var t = window.PR_SHOULD_USE_CONTINUATION ? j.now() + 250 : Infinity; q < o.length && j.now() < t; q++) {
                          var p = o[q];
                
                          if (p.className && p.className.indexOf("prettyprint") >= 0) {
                Severity: Major
                Found in lib/html/pretty-print.js - About 2 hrs to fix

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

                        function o(c) {
                          var d = c.substring(1, c.length - 1).match(RegExp("\\\\u[0-9A-Fa-f]{4}|\\\\x[0-9A-Fa-f]{2}|\\\\[0-3][0-7]{0,2}|\\\\[0-7]{1,2}|\\\\[\\s\\S]|-|[^-\\\\]", "g"));
                          c = [];
                  
                          for (var a = [], k = d[0] === "^", e = k ? 1 : 0, h = d.length; e < h; ++e) {
                  Severity: Minor
                  Found in lib/html/pretty-print.js - About 2 hrs to fix

                    Function n has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          function n(r) {
                            for (var j = r.c, q = [j, z], m = 0, t = r.source.match(o) || [], p = {}, c = 0, d = t.length; c < d; ++c) {
                              var a = t[c],
                                  k = p[a],
                                  e = void 0,
                    Severity: Minor
                    Found in lib/html/pretty-print.js - About 1 hr to fix

                      Function H has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          function H(b, f, i) {
                            switch (b.nodeType) {
                              case 1:
                                var o = b.tagName.toLowerCase();
                                f.push("<", o);
                      Severity: Minor
                      Found in lib/html/pretty-print.js - About 1 hr to fix

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

                              function f(c) {
                                if (c.charAt(0) !== "\\") return c.charCodeAt(0);
                        
                                switch (c.charAt(1)) {
                                  case "b":
                        Severity: Minor
                        Found in lib/html/pretty-print.js - About 1 hr to fix

                          Function l has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                function l(c) {
                                  for (var d = c.source.match(RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)", "g")), a = d.length, k = [], e = 0, h = 0; e < a; ++e) {
                                    var g = d[e];
                                    if (g === "(") ++h;else if ("\\" === g.charAt(0)) if ((g = +g.substring(1)) && g <= h) k[g] = -1;
                                  }
                          Severity: Minor
                          Found in lib/html/pretty-print.js - About 1 hr to fix

                            Avoid deeply nested control flow statements.
                            Open

                                          for (var r = [], j = n; --j >= 0;) {
                                            r[j] = l[j];
                                          }
                            Severity: Major
                            Found in lib/html/pretty-print.js - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                            if (K) {
                                              d = a.innerHTML;
                                              if ("XMP" === a.tagName) d = y(d);else {
                                                a = a;
                                                if ("PRE" === a.tagName) a = true;else if (ka.test(d)) {
                              Severity: Major
                              Found in lib/html/pretty-print.js - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                            if (k < 0) a = p;else {
                                              for (--k; (k = p.indexOf("&#", k + 1)) >= 0;) {
                                                var e = p.indexOf(";", k);
                                
                                                if (e >= 0) {
                                Severity: Major
                                Found in lib/html/pretty-print.js - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                if ((a.tagName === "pre" || a.tagName === "code" || a.tagName === "xmp") && a.className && a.className.indexOf("prettyprint") >= 0) {
                                                  d = true;
                                                  break;
                                                }
                                  Severity: Major
                                  Found in lib/html/pretty-print.js - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                if (!ba.test(m)) if (ca.test(m)) {
                                                  f.push(m.substring(9, m.length - 3));
                                                  n += m.length - 12;
                                                } else if (da.test(m)) {
                                                  f.push("\n");
                                    Severity: Major
                                    Found in lib/html/pretty-print.js - About 45 mins to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                                    for (h = 0; h < l; ++h) {
                                                      g = f[h];
                                      
                                                      if (e = a.match(g[1])) {
                                                        k = g[0];
                                      Severity: Major
                                      Found in lib/html/pretty-print.js - About 45 mins to fix

                                        Avoid deeply nested control flow statements.
                                        Open

                                                  } else if ("\\" === g.charAt(0)) if ((g = +g.substring(1)) && g <= h) d[e] = "\\" + k[h];
                                        Severity: Major
                                        Found in lib/html/pretty-print.js - About 45 mins to fix

                                          Avoid deeply nested control flow statements.
                                          Open

                                                        if (null === K) {
                                                          d = document.createElement("PRE");
                                                          d.appendChild(document.createTextNode('<!DOCTYPE foo PUBLIC "foo bar">\n<foo />'));
                                                          K = !/</.test(d.innerHTML);
                                                        }
                                          Severity: Major
                                          Found in lib/html/pretty-print.js - About 45 mins to fix

                                            Avoid deeply nested control flow statements.
                                            Open

                                                          if (p = m.a) {
                                                            c = m.b;
                                            
                                                            if ("XMP" === c.tagName) {
                                                              d = document.createElement("PRE");
                                            Severity: Major
                                            Found in lib/html/pretty-print.js - About 45 mins to fix

                                              Consider simplifying this complex logical expression.
                                              Open

                                                        if (!(s < 65 || g > 122)) {
                                                          s < 65 || g > 90 || a.push([Math.max(65, g) | 32, Math.min(s, 90) | 32]);
                                                          s < 97 || g > 122 || a.push([Math.max(97, g) & -33, Math.min(s, 122) & -33]);
                                                        }
                                              Severity: Major
                                              Found in lib/html/pretty-print.js - About 40 mins to fix

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

                                                if (typeof prettyPrint === "undefined") {
                                                  // prettify.js
                                                  // http://code.google.com/p/google-code-prettify/
                                                  // prettier-ignore
                                                  window.PR_SHOULD_USE_CONTINUATION = true;
                                                Severity: Major
                                                Found in lib/html/pretty-print.js and 1 other location - About 1 mo to fix
                                                lib/html/vendor.js on lines 37..846

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

                                                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