ContentMine/thresher

View on GitHub

Showing 115 of 227 total issues

Avoid deeply nested control flow statements.
Open

                    if (name == "div") {
                        types.push(XPathParser.DIV);
                        values.push(name);
                        continue;
                    }
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

                              do {
                                  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

                    if (!e.selector) {
                      problems.push('element ' + k + ' has no selector');
                    }
        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

                                  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

                                    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 (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 (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

                                          if (xpc.contextNode.nodeType == 2 /*Node.ATTRIBUTE_NODE*/) {
                                              m = this.getOwnerElement(xpc.contextNode);
                                          } else {
                                              m = xpc.contextNode.parentNode;
                                          }
                  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

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

                      ElementQueue.prototype.addElement = function(e) {
                        var eq = this;
                        // We keep track of which elements
                        // are followed by others, so we can rapidly
                        // decide which ones needs adjusting in the queue
                      Severity: Minor
                      Found in lib/elementQueue.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 (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

                        Avoid deeply nested control flow statements.
                        Open

                                            if (this.predicateMatches(pred, xpc)) {
                                                newNodes.push(xpc.contextNode);
                                            } else {
                                            }
                        Severity: Major
                        Found in lib/xpath.js - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

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

                            Avoid deeply nested control flow statements.
                            Open

                                                while (Utilities.isNCNameChar(c.charCodeAt(0))) {
                                                    name += c;
                                                    c = s.charAt(pos++);
                                                }
                            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 (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 !== xpc.virtualRoot) {
                                                              if (xpc.contextNode.nodeType == 2 /*Node.ATTRIBUTE_NODE*/) {
                                                                  m = this.getOwnerElement(xpc.contextNode);
                                                              } else {
                                                                  m = xpc.contextNode.parentNode;
                                  Severity: Major
                                  Found in lib/xpath.js - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

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