ContentMine/thresher

View on GitHub

Showing 115 of 227 total issues

Function add has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

AVLTree.prototype.add = function(n)  {
    if (n === this.node) {
        return false;
    }
    
Severity: Minor
Found in lib/xpath.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 XPathResult has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function XPathResult(v, t) {
    if (t == XPathResult.ANY_TYPE) {
        if (v.constructor === XString) {
            t = XPathResult.STRING_TYPE;
        } else if (v.constructor === XNumber) {
Severity: Minor
Found in lib/xpath.js - About 1 hr to fix

    Function toString has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    Step.prototype.toString = function() {
        var s;
        switch (this.axis) {
            case Step.ANCESTOR:
                s = "ancestor";
    Severity: Minor
    Found in lib/xpath.js - About 1 hr to fix

      Function scrapeElement has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      Scraper.prototype.scrapeElement = function(doc, element, scrapeUrl, key, follow_url) {
        var scraper = this;
        follow_url = typeof follow_url !== 'undefined' ? follow_url : false;
        // extract element
        key = key || element.name;
      Severity: Minor
      Found in lib/scraper.js - About 1 hr to fix

        Function validate has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        Scraper.prototype.validate = function(def){
          var problems = [];
          // url key must exist
          if (!def.url) {
            problems.push('must have "url" key');
        Severity: Minor
        Found in lib/scraper.js - About 1 hr to fix

          Function matches has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          NodeTest.prototype.matches = function(n, xpc) {
              switch (this.type) {
                  case NodeTest.NAMETESTANY:
                      if (n.nodeType == 2 /*Node.ATTRIBUTE_NODE*/
                              || n.nodeType == 1 /*Node.ELEMENT_NODE*/
          Severity: Minor
          Found in lib/xpath.js - About 1 hr to fix

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

            AVLTree.prototype.order = function(n1, n2) {
                if (n1 === n2) {
                    return 0;
                }
                var d1 = 0;
            Severity: Minor
            Found in lib/xpath.js - About 1 hr to fix

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

              PathExpr.prototype.toString = function() {
                  if (this.filter != undefined) {
                      var s = this.filter.toString();
                      if (Utilities.instance_of(this.filter, XString)) {
                          s = "'" + s + "'";
              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 normalizeSpace has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

              Functions.normalizeSpace = function() {
                  var c = arguments[0];
                  var s;
                  if (arguments.length == 1) {
                      s = XNodeSet.prototype.stringForNode(c.contextNode);
              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 XPathResult has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

              function XPathResult(v, t) {
                  if (t == XPathResult.ANY_TYPE) {
                      if (v.constructor === XString) {
                          t = XPathResult.STRING_TYPE;
                      } else if (v.constructor === XNumber) {
              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 getNamespace has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

              NamespaceResolver.prototype.getNamespace = function(prefix, n) {
                  if (prefix == "xml") {
                      return XPath.XML_NAMESPACE_URI;
                  } else if (prefix == "xmlns") {
                      return XPath.XMLNS_NAMESPACE_URI;
              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 render has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              HeadlessRenderer.prototype.render = function(scrapeUrl, actions, cookiejar) {
                var renderer = this;
                var settings = renderer.settings('debug');
                var spooky = new Spooky(settings, function() {
                  spooky.start(scrapeUrl);
              Severity: Minor
              Found in lib/renderer/headless.js - About 1 hr to fix

                Function settings has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                HeadlessRenderer.prototype.settings = function(loglevel) {
                  env['PHANTOMJS_EXECUTABLE'] = deps.getbinpath('phantomjs');
                  return {
                    child: {
                      command: deps.getbinpath('casperjs'),
                Severity: Minor
                Found in lib/renderer/headless.js - About 1 hr to fix

                  Function translate has a Cognitive Complexity of 11 (exceeds 5 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

                  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 parse has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                  XPathParser.prototype.parse = function(s) {
                      var types;
                      var values;
                      var res = this.tokenize(s);
                      if (res == undefined) {
                  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 scrapeUrl has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  Scraper.prototype.scrapeUrl = function(theUrl, node) {
                    var scraper = this;
                    scraper.startTicker();
                    scraper.results = scraper.results || {};
                    node = node || scraper.tree.root;
                  Severity: Minor
                  Found in lib/scraper.js - About 1 hr to fix

                    Function scrape has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    Thresher.prototype.scrape = function(scrapeUrl, headless) {
                      var thresher = this;
                      thresher.emit('scrapeStart', scrapeUrl);
                    
                      // validate arguments
                    Severity: Minor
                    Found in lib/thresher.js - About 1 hr to fix

                      Function add has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      AVLTree.prototype.add = function(n)  {
                          if (n === this.node) {
                              return false;
                          }
                          
                      Severity: Minor
                      Found in lib/xpath.js - About 1 hr to fix

                        Function normalizeSpace has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        Functions.normalizeSpace = function() {
                            var c = arguments[0];
                            var s;
                            if (arguments.length == 1) {
                                s = XNodeSet.prototype.stringForNode(c.contextNode);
                        Severity: Minor
                        Found in lib/xpath.js - About 1 hr to fix

                          Function id has 29 lines of code (exceeds 25 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
                            Severity
                            Category
                            Status
                            Source
                            Language