pixels-and-bits/jabe

View on GitHub
app/assets/javascripts/jabe/prettify.js

Summary

Maintainability
F
1 wk
Test Coverage

File prettify.js has 902 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// Copyright (C) 2006 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
Severity: Major
Found in app/assets/javascripts/jabe/prettify.js - About 2 days to fix

    Function combinePrefixPatterns has 186 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      function combinePrefixPatterns(regexs) {
        var capturedGroupIndex = 0;
      
        var needToFoldCase = false;
        var ignoreCase = false;
    Severity: Major
    Found in app/assets/javascripts/jabe/prettify.js - About 7 hrs to fix

      Function numberLines has 98 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        function numberLines(node, opt_startLineNum) {
          var nocode = /(?:^|\s)nocode(?:\s|$)/;
          var lineBreak = /\r\n?|\n/;
        
          var document = node.ownerDocument;
      Severity: Major
      Found in app/assets/javascripts/jabe/prettify.js - About 3 hrs to fix

        Function createSimpleLexer has 94 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          function createSimpleLexer(shortcutStylePatterns, fallthroughStylePatterns) {
            var shortcuts = {};
            var tokenizer;
            (function () {
              var allPatterns = shortcutStylePatterns.concat(fallthroughStylePatterns);
        Severity: Major
        Found in app/assets/javascripts/jabe/prettify.js - About 3 hrs to fix

          Function sourceDecorator has 78 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            function sourceDecorator(options) {
              var shortcutStylePatterns = [], fallthroughStylePatterns = [];
              if (options['tripleQuotedStrings']) {
                // '''multi-line-string''', 'single-line-string', and double-quoted
                shortcutStylePatterns.push(
          Severity: Major
          Found in app/assets/javascripts/jabe/prettify.js - About 3 hrs to fix

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

              function recombineTagsAndDecorations(job) {
                var isIE = /\bMSIE\b/.test(navigator.userAgent);
                var newlineRe = /\n/g;
              
                var source = job.sourceCode;
            Severity: Major
            Found in app/assets/javascripts/jabe/prettify.js - About 2 hrs to fix

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

                  var decorate = function (job) {
                    var sourceCode = job.sourceCode, basePos = job.basePos;
                    /** Even entries are positions in source in ascending order.  Odd enties
                      * are style markers (e.g., PR_COMMENT) that run from that position until
                      * the end.
              Severity: Major
              Found in app/assets/javascripts/jabe/prettify.js - About 2 hrs to fix

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

                    function allowAnywhereFoldCaseAndRenumberGroups(regex) {
                      // Split into character sets, escape sequences, punctuation strings
                      // like ('(', '(?:', ')', '^'), and runs of characters that do not
                      // include any of the above.
                      var parts = regex.source.match(
                Severity: Major
                Found in app/assets/javascripts/jabe/prettify.js - About 2 hrs to fix

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

                    function prettyPrint(opt_whenDone) {
                      function byTagName(tn) { return document.getElementsByTagName(tn); }
                      // fetch a list of nodes to rewrite
                      var codeSegments = [byTagName('pre'), byTagName('code'), byTagName('xmp')];
                      var elements = [];
                  Severity: Major
                  Found in app/assets/javascripts/jabe/prettify.js - About 2 hrs to fix

                    Function caseFoldCharset has 61 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        function caseFoldCharset(charSet) {
                          var charsetParts = charSet.substring(1, charSet.length - 1).match(
                              new RegExp(
                                  '\\\\u[0-9A-Fa-f]{4}'
                                  + '|\\\\x[0-9A-Fa-f]{2}'
                    Severity: Major
                    Found in app/assets/javascripts/jabe/prettify.js - About 2 hrs to fix

                      Function extractSourceSpans has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        function extractSourceSpans(node) {
                          var nocode = /(?:^|\s)nocode(?:\s|$)/;
                        
                          var chunks = [];
                          var length = 0;
                      Severity: Minor
                      Found in app/assets/javascripts/jabe/prettify.js - About 1 hr to fix

                        Function doWork has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            function doWork() {
                              var endTime = (window['PR_SHOULD_USE_CONTINUATION'] ?
                                             clock['now']() + 250 /* ms */ :
                                             Infinity);
                              for (; k < elements.length && clock['now']() < endTime; k++) {
                        Severity: Minor
                        Found in app/assets/javascripts/jabe/prettify.js - About 1 hr to fix

                          Function walk has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              function walk(node) {
                                switch (node.nodeType) {
                                  case 1:  // Element
                                    if (nocode.test(node.className)) { break; }
                                    if ('BR' === node.nodeName) {
                          Severity: Minor
                          Found in app/assets/javascripts/jabe/prettify.js - About 1 hr to fix

                            Function walk has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                function walk(node) {
                                  switch (node.nodeType) {
                                    case 1:  // Element
                                      if (nocode.test(node.className)) { return; }
                                      for (var child = node.firstChild; child; child = child.nextSibling) {
                            Severity: Minor
                            Found in app/assets/javascripts/jabe/prettify.js - About 1 hr to fix

                              Avoid deeply nested control flow statements.
                              Open

                                            if (match) {
                                              style = patternParts[0];
                                              break;
                                            }
                              Severity: Major
                              Found in app/assets/javascripts/jabe/prettify.js - About 45 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                        return charsetPart.charCodeAt(1);
                                Severity: Major
                                Found in app/assets/javascripts/jabe/prettify.js - About 30 mins to fix

                                  There are no issues that match your filters.

                                  Category
                                  Status