ContentMine/thresher

View on GitHub

Showing 115 of 227 total issues

Avoid deeply nested control flow statements.
Open

                        if (xpc.virtualRoot != null) {
                            st = [ xpc.virtualRoot ];
                        } else {
                            st = xpc.contextNode.nodeType == 9 /*Node.DOCUMENT_NODE*/
                                ? [ xpc.contextNode ]
Severity: Major
Found in lib/xpath.js - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if (s.charAt(pos) == ')') {
                            types.push(XPathParser.NODETYPE);
                        } else {
                            types.push(XPathParser.PROCESSINGINSTRUCTIONWITHLITERAL);
                        }
    Severity: Major
    Found in lib/xpath.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if (xpc.contextNode === xpc.virtualRoot) {
                                  break;
                              }
      Severity: Major
      Found in lib/xpath.js - About 45 mins to fix

        Function getChildElements has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        function getChildElements(obj) {
          var elementsArray = [];
          // process followables first, they
          // will be excluded from results later
          if (obj.followables) {
        Severity: Minor
        Found in lib/scraper.js - About 45 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

        Avoid deeply nested control flow statements.
        Open

                            if (name == "mod") {
                                types.push(XPathParser.MOD);
                                values.push(name);
                                continue;
                            }
        Severity: Major
        Found in lib/xpath.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if (xpc.contextNode.firstChild != null) {
                                      st.unshift(xpc.contextNode.firstChild);
                                  } else {
                                      st.unshift(xpc.contextNode.nextSibling);
                                  }
          Severity: Major
          Found in lib/xpath.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if (xpc.contextNode.nodeType == 1 /*Node.ELEMENT_NODE*/) {
                                        n["xml"] = XPath.XML_NAMESPACE_URI;
                                        n["xmlns"] = XPath.XMLNS_NAMESPACE_URI;
                                        for (var m = xpc.contextNode; m != null && m.nodeType == 1 /*Node.ELEMENT_NODE*/; m = m.parentNode) {
                                            for (var k = 0; k < m.attributes.length; k++) {
            Severity: Major
            Found in lib/xpath.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      for (var m = xpc.contextNode.previousSibling; m != null; m = m.previousSibling) {
                                          if (step.nodeTest.matches(m, xpc)) {
                                              newNodes.push(m);
                                          }
                                      }
              Severity: Major
              Found in lib/xpath.js - About 45 mins to fix

                Function scrapeElement has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                Scraper.prototype.scrapeElement = function(doc, element, scrapeUrl, key, follow_url) {
                Severity: Minor
                Found in lib/scraper.js - About 35 mins to fix

                  Function evaluate has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      doc.evaluate = function(e, cn, r, t, res) {
                  Severity: Minor
                  Found in lib/xpath.js - About 35 mins to fix

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

                    var Scraper = function(definition, headless) {
                      var scraper = this;
                    
                      EventEmitter2.call(this, {
                        wildcard: true,
                    Severity: Minor
                    Found in lib/scraper.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

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

                    Functions.name = function() {
                        var c = arguments[0];
                        var n;
                        if (arguments.length == 1) {
                            n = c.contextNode;
                    Severity: Minor
                    Found in lib/xpath.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

                    Avoid too many return statements within this function.
                    Open

                                return Step.PARENT;
                    Severity: Major
                    Found in lib/xpath.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                  return Step.PRECEDINGSIBLING;
                      Severity: Major
                      Found in lib/xpath.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                    return Step.DESCENDANT;
                        Severity: Major
                        Found in lib/xpath.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                      return Step.NAMESPACE;
                          Severity: Major
                          Found in lib/xpath.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                        return false;
                            Severity: Major
                            Found in lib/xpath.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                  return false;
                              Severity: Major
                              Found in lib/xpath.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                                return;
                                Severity: Major
                                Found in lib/xpath.js - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                          return -1;
                                  Severity: Major
                                  Found in lib/xpath.js - About 30 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language