ContentMine/thresher

View on GitHub

Showing 115 of 227 total issues

Function addElement has 28 lines of code (exceeds 25 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 1 hr to fix

    Function Scraper has 28 lines of code (exceeds 25 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 1 hr to fix

      Function id has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      Functions.id = function() {
          var c = arguments[0];
          var id;
          if (arguments.length != 2) {
              throw new Error("Function id expects (object)");
      Severity: Minor
      Found in lib/xpath.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 getOwnerElement has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      PathExpr.prototype.getOwnerElement = function(n) {
          // DOM 2 has ownerElement
          if (n.ownerElement) {
              return n.ownerElement;
          }
      Severity: Minor
      Found in lib/xpath.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 coalesceText has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      Utilities.coalesceText = function(n) {
          for (var m = n.firstChild; m != null; m = m.nextSibling) {
              if (m.nodeType == 3 /*Node.TEXT_NODE*/ || m.nodeType == 4 /*Node.CDATA_SECTION_NODE*/) {
                  var s = m.nodeValue;
                  var first = m;
      Severity: Minor
      Found in lib/xpath.js - About 1 hr to fix

        Function addStandardFunctions has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        FunctionResolver.prototype.addStandardFunctions = function() {
            this.functions["{}last"] = Functions.last;
            this.functions["{}position"] = Functions.position;
            this.functions["{}count"] = Functions.count;
            this.functions["{}id"] = Functions.id;
        Severity: Minor
        Found in lib/xpath.js - About 1 hr to fix

          Function translate has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          Functions.translate = function() {
              var c = arguments[0];
              if (arguments.length != 4) {
                  throw new Error("Function translate expects (string, string, string)");
              }
          Severity: Minor
          Found in lib/xpath.js - About 1 hr to fix

            Function runRegex has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            Scraper.prototype.runRegex = function(string, regex) {
              var re;
              if (regex instanceof Object) {
                if (regex.flags) {
                  var flags = regex.flags.join('');
            Severity: Minor
            Found in lib/scraper.js - About 55 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 checkUrl has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            url.checkUrl = function(theUrl) {
              var protocol = /^(f|ht)tps?:\/\//i.test(theUrl);
              var domain = /:\/\/\w+(\.[^:]+)*([:\/].+)*$/i.test(theUrl);
              if (!protocol || !domain) {
                // not a valid URL
            Severity: Minor
            Found in lib/url.js - About 55 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 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 (!e.selector) {
                          problems.push('element ' + k + ' has no selector');
                        }
            Severity: Major
            Found in lib/scraper.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  while (c >= '0' && c <= '9') {
                                      number += c;
                                      c = s.charAt(pos++);
                                  }
              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

                  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

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

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