ContentMine/thresher

View on GitHub

Showing 115 of 227 total issues

File xpath.js has 3704 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 * xpath.js
 *
 * An XPath 1.0 library for JavaScript.
 *
Severity: Major
Found in lib/xpath.js - About 1 wk to fix

    Function evaluate has a Cognitive Complexity of 407 (exceeds 5 allowed). Consider refactoring.
    Open

    PathExpr.prototype.evaluate = function(c) {
        var nodes;
        var xpc = new XPathContext();
        xpc.variableResolver = c.variableResolver;
        xpc.functionResolver = c.functionResolver;
    Severity: Minor
    Found in lib/xpath.js - About 1 wk 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 isLetter has a Cognitive Complexity of 303 (exceeds 5 allowed). Consider refactoring.
    Open

    Utilities.isLetter = function(c) {
        return c >= 0x0041 && c <= 0x005A ||
            c >= 0x0061 && c <= 0x007A ||
            c >= 0x00C0 && c <= 0x00D6 ||
            c >= 0x00D8 && c <= 0x00F6 ||
    Severity: Minor
    Found in lib/xpath.js - About 6 days 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 tokenize has a Cognitive Complexity of 177 (exceeds 5 allowed). Consider refactoring.
    Open

    XPathParser.prototype.tokenize = function(s1) {
        var types = [];
        var values = [];
        var s = s1 + '\0';
    
    Severity: Minor
    Found in lib/xpath.js - About 3 days 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 isNCNameChar has a Cognitive Complexity of 166 (exceeds 5 allowed). Consider refactoring.
    Open

    Utilities.isNCNameChar = function(c) {
        return c >= 0x0030 && c <= 0x0039 
            || c >= 0x0660 && c <= 0x0669 
            || c >= 0x06F0 && c <= 0x06F9 
            || c >= 0x0966 && c <= 0x096F 
    Severity: Minor
    Found in lib/xpath.js - About 3 days 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 tokenize has 333 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    XPathParser.prototype.tokenize = function(s1) {
        var types = [];
        var values = [];
        var s = s1 + '\0';
    
    Severity: Major
    Found in lib/xpath.js - About 1 day to fix

      Function evaluate has 277 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      PathExpr.prototype.evaluate = function(c) {
          var nodes;
          var xpc = new XPathContext();
          xpc.variableResolver = c.variableResolver;
          xpc.functionResolver = c.functionResolver;
      Severity: Major
      Found in lib/xpath.js - About 1 day to fix

        Function init has 207 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        XPathParser.prototype.init = function() {
            this.reduceActions = [];
        
            this.reduceActions[3] = function(rhs) {
                return new OrOperation(rhs[0], rhs[2]);
        Severity: Major
        Found in lib/xpath.js - About 1 day to fix

          Function isLetter has 205 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          Utilities.isLetter = function(c) {
              return c >= 0x0041 && c <= 0x005A ||
                  c >= 0x0061 && c <= 0x007A ||
                  c >= 0x00C0 && c <= 0x00D6 ||
                  c >= 0x00D8 && c <= 0x00F6 ||
          Severity: Major
          Found in lib/xpath.js - About 1 day to fix

            Function validate has a Cognitive Complexity of 43 (exceeds 5 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 6 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

            Consider simplifying this complex logical expression.
            Open

                            if (last != XPathParser.AT
                                    && last != XPathParser.DOUBLECOLON
                                    && last != XPathParser.LEFTPARENTHESIS
                                    && last != XPathParser.LEFTBRACKET
                                    && last != XPathParser.AND
            Severity: Critical
            Found in lib/xpath.js - About 5 hrs to fix

              Consider simplifying this complex logical expression.
              Open

                              if (last != XPathParser.AT
                                      && last != XPathParser.DOUBLECOLON
                                      && last != XPathParser.LEFTPARENTHESIS
                                      && last != XPathParser.LEFTBRACKET
                                      && last != XPathParser.AND
              Severity: Critical
              Found in lib/xpath.js - About 5 hrs to fix

                Function isNCNameChar has 125 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                Utilities.isNCNameChar = function(c) {
                    return c >= 0x0030 && c <= 0x0039 
                        || c >= 0x0660 && c <= 0x0669 
                        || c >= 0x06F0 && c <= 0x06F9 
                        || c >= 0x0966 && c <= 0x096F 
                Severity: Major
                Found in lib/xpath.js - About 5 hrs to fix

                  Function matches has a Cognitive Complexity of 27 (exceeds 5 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 3 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 scrapeElement has a Cognitive Complexity of 23 (exceeds 5 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 3 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 coalesceText has a Cognitive Complexity of 22 (exceeds 5 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 3 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

                  File scraper.js has 283 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  // # Scraper
                  //
                  // > Scraper class in the Node.js Thresher package.
                  // >
                  // > author: [Richard Smith-Unna](http://blahah/net)
                  Severity: Minor
                  Found in lib/scraper.js - About 2 hrs to fix

                    Function parse has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    XPathParser.prototype.parse = function(s) {
                        var types;
                        var values;
                        var res = this.tokenize(s);
                        if (res == undefined) {
                    Severity: Major
                    Found in lib/xpath.js - About 2 hrs to fix

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

                      AVLTree.prototype.balance = function() {
                          var ldepth = this.left  == null ? 0 : this.left.depth;
                          var rdepth = this.right == null ? 0 : this.right.depth;
                      
                          if (ldepth > rdepth + 1) {
                      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 order has a Cognitive Complexity of 16 (exceeds 5 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 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

                      Severity
                      Category
                      Status
                      Source
                      Language