ContentMine/thresher

View on GitHub

Showing 115 of 227 total issues

Avoid deeply nested control flow statements.
Open

            if (keywords.indexOf(j) == -1) {
              // this element has child[ren]
              isLeaf = false;
              checkLeaves(e);
            }
Severity: Major
Found in lib/scraper.js - About 45 mins to fix

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

    Utilities.resolveQName = function(qn, nr, n, useDefault) {
        var parts = Utilities.splitQName(qn);
        if (parts[0] != null) {
            parts[0] = nr.getNamespace(parts[0], n);
        } else {
    Severity: Minor
    Found in lib/xpath.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 (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 (this.predicateMatches(pred, xpc)) {
                              newNodes.push(xpc.contextNode);
                          }
      Severity: Major
      Found in lib/xpath.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if (nodes[0].ownerDocument == null) {
                                // IE 5.5 doesn't have ownerDocument?
                                var n = nodes[0];
                                while (n.parentNode != null) {
                                    n = n.parentNode;
        Severity: Major
        Found in lib/xpath.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

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

            Avoid deeply nested control flow statements.
            Open

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

              Avoid deeply nested control flow statements.
              Open

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

                Avoid deeply nested control flow statements.
                Open

                                        if (nnm != null) {
                                            for (var k = 0; k < nnm.length; k++) {
                                                var m = nnm.item(k);
                                                if (step.nodeTest.matches(m, xpc)) {
                                                    newNodes.push(m);
                Severity: Major
                Found in lib/xpath.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if (step.nodeTest.matches(xpc.contextNode, xpc)) {
                                              newNodes.push(xpc.contextNode);
                                          }
                  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

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

                        Avoid deeply nested control flow statements.
                        Open

                                                for (var m = xpc.contextNode.parentNode; m != null && m.nodeType != 9 /*Node.DOCUMENT_NODE*/ && m !== xpc.virtualRoot; m = m.parentNode) {
                                                    st.unshift(m.nextSibling);
                                                }
                        Severity: Major
                        Found in lib/xpath.js - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

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

                            Avoid deeply nested control flow statements.
                            Open

                                                    outer: while (st.length > 0) {
                                                        for (var m = st.pop(); m != null; ) {
                                                            if (m == xpc.contextNode) {
                                                                break outer;
                                                            }
                            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

                                Avoid deeply nested control flow statements.
                                Open

                                                        for (var m = xpc.contextNode; m != null; m = m.nodeType == 2 /*Node.ATTRIBUTE_NODE*/ ? this.getOwnerElement(m) : m.parentNode) {
                                                            if (step.nodeTest.matches(m, xpc)) {
                                                                newNodes.push(m);
                                                            }
                                                            if (m === xpc.virtualRoot) {
                                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

                                    Avoid deeply nested control flow statements.
                                    Open

                                                        if (c == '(') {
                                                            types.push(XPathParser.FUNCTIONNAME);
                                                            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.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
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language