doc/sh_main.js

Summary

Maintainability
F
5 days
Test Coverage

Function sh_highlightString has a Cognitive Complexity of 104 (exceeds 5 allowed). Consider refactoring.
Open

function sh_highlightString(inputString, language) {
  if (/Konqueror/.test(navigator.userAgent)) {
    if (! language.konquered) {
      for (var s = 0; s < language.length; s++) {
        for (var p = 0; p < language[s].length; p++) {
Severity: Minor
Found in doc/sh_main.js - About 2 days 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 sh_highlightString has 157 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function sh_highlightString(inputString, language) {
  if (/Konqueror/.test(navigator.userAgent)) {
    if (! language.konquered) {
      for (var s = 0; s < language.length; s++) {
        for (var p = 0; p < language[s].length; p++) {
Severity: Major
Found in doc/sh_main.js - About 6 hrs to fix

    File sh_main.js has 414 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*
    SHJS - Syntax Highlighting in JavaScript
    Copyright (C) 2007, 2008 gnombat@users.sourceforge.net
    License: http://shjs.sourceforge.net/doc/gplv3.html
    */
    Severity: Minor
    Found in doc/sh_main.js - About 5 hrs to fix

      Function highlight has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

      function highlight(prefix, suffix, tag) {
        var nodeList = document.getElementsByTagName(tag);
        for (var i = 0; i < nodeList.length; i++) {
          var element = nodeList.item(i);
          var htmlClasses = sh_getClasses(element);
      Severity: Minor
      Found in doc/sh_main.js - About 2 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

      Function sh_mergeTags has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function sh_mergeTags(originalTags, highlightTags) {
        var numOriginalTags = originalTags.length;
        if (numOriginalTags === 0) {
          return highlightTags;
        }
      Severity: Minor
      Found in doc/sh_main.js - About 1 hr to fix

        Function sh_extractTagsFromNodeList has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        function sh_extractTagsFromNodeList(nodeList, result) {
          var length = nodeList.length;
          for (var i = 0; i < length; i++) {
            var node = nodeList.item(i);
            switch (node.nodeType) {
        Severity: Minor
        Found in doc/sh_main.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 sh_insertTags has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        function sh_insertTags(tags, text) {
          var doc = document;
        
          var result = document.createDocumentFragment();
          var tagIndex = 0;
        Severity: Minor
        Found in doc/sh_main.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 sh_mergeTags has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        function sh_mergeTags(originalTags, highlightTags) {
          var numOriginalTags = originalTags.length;
          if (numOriginalTags === 0) {
            return highlightTags;
          }
        Severity: Minor
        Found in doc/sh_main.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 output has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          var output = function(s, style) {
            var length = s.length;
            // this is more than just an optimization - we don't want to output empty <span></span> elements
            if (length === 0) {
              return;
        Severity: Minor
        Found in doc/sh_main.js - About 1 hr to fix

          Function sh_insertTags has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function sh_insertTags(tags, text) {
            var doc = document;
          
            var result = document.createDocumentFragment();
            var tagIndex = 0;
          Severity: Minor
          Found in doc/sh_main.js - About 1 hr to fix

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

            function sh_load(language, element, prefix, suffix) {
              if (language in sh_requests) {
                sh_requests[language].push(element);
                return;
              }
            Severity: Minor
            Found in doc/sh_main.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 highlight has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function highlight(prefix, suffix, tag) {
              var nodeList = document.getElementsByTagName(tag);
              for (var i = 0; i < nodeList.length; i++) {
                var element = nodeList.item(i);
                var htmlClasses = sh_getClasses(element);
            Severity: Minor
            Found in doc/sh_main.js - About 1 hr to fix

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

              function sh_extractTagsFromNodeList(nodeList, result) {
                var length = nodeList.length;
                for (var i = 0; i < length; i++) {
                  var node = nodeList.item(i);
                  switch (node.nodeType) {
              Severity: Minor
              Found in doc/sh_main.js - About 1 hr to fix

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

                function sh_load(language, element, prefix, suffix) {
                  if (language in sh_requests) {
                    sh_requests[language].push(element);
                    return;
                  }
                Severity: Minor
                Found in doc/sh_main.js - About 1 hr to fix

                  Avoid deeply nested control flow statements.
                  Open

                            if (r.source === '$') {
                              r.exec = sh_konquerorExec;
                            }
                  Severity: Major
                  Found in doc/sh_main.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                              for (var subexpression = 0; subexpression < newStyle.length; subexpression++) {
                                matchedString = bestMatch[subexpression + 1];
                                output(matchedString, newStyle[subexpression]);
                              }
                    Severity: Major
                    Found in doc/sh_main.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                if (match.index === posWithinLine) {
                                  break;
                                }
                      Severity: Major
                      Found in doc/sh_main.js - About 45 mins to fix

                        Function sh_getClasses has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                        function sh_getClasses(element) {
                          var result = [];
                          var htmlClass = element.className;
                          if (htmlClass && htmlClass.length > 0) {
                            var htmlClasses = htmlClass.split(' ');
                        Severity: Minor
                        Found in doc/sh_main.js - About 35 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

                        There are no issues that match your filters.

                        Category
                        Status