ContentMine/thresher

View on GitHub

Showing 227 of 227 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    for (var i = 0; i < this.arguments.length; i++) {
        if (i > 0) {
            s += ", ";
        }
        s += this.arguments[i].toString();
Severity: Major
Found in lib/xpath.js and 1 other location - About 1 hr to fix
lib/xpath.js on lines 2050..2055

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 71.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    for (var i = 0; i < this.steps.length; i++) {
        if (i != 0) {
            s += "/";
        }
        s += this.steps[i].toString();
Severity: Major
Found in lib/xpath.js and 1 other location - About 1 hr to fix
lib/xpath.js on lines 2299..2304

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 71.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 6 locations. Consider refactoring.
Open

MultiplyOperation.prototype.evaluate = function(c) {
    return this.lhs.evaluate(c).number().multiply(this.rhs.evaluate(c).number());
};
Severity: Major
Found in lib/xpath.js and 5 other locations - About 1 hr to fix
lib/xpath.js on lines 1508..1510
lib/xpath.js on lines 1532..1534
lib/xpath.js on lines 1580..1582
lib/xpath.js on lines 1604..1606
lib/xpath.js on lines 1628..1630

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 70.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 6 locations. Consider refactoring.
Open

DivOperation.prototype.evaluate = function(c) {
    return this.lhs.evaluate(c).number().div(this.rhs.evaluate(c).number());
};
Severity: Major
Found in lib/xpath.js and 5 other locations - About 1 hr to fix
lib/xpath.js on lines 1508..1510
lib/xpath.js on lines 1532..1534
lib/xpath.js on lines 1556..1558
lib/xpath.js on lines 1604..1606
lib/xpath.js on lines 1628..1630

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 70.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 6 locations. Consider refactoring.
Open

ModOperation.prototype.evaluate = function(c) {
    return this.lhs.evaluate(c).number().mod(this.rhs.evaluate(c).number());
};
Severity: Major
Found in lib/xpath.js and 5 other locations - About 1 hr to fix
lib/xpath.js on lines 1508..1510
lib/xpath.js on lines 1532..1534
lib/xpath.js on lines 1556..1558
lib/xpath.js on lines 1580..1582
lib/xpath.js on lines 1628..1630

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 70.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 6 locations. Consider refactoring.
Open

PlusOperation.prototype.evaluate = function(c) {
    return this.lhs.evaluate(c).number().plus(this.rhs.evaluate(c).number());
};
Severity: Major
Found in lib/xpath.js and 5 other locations - About 1 hr to fix
lib/xpath.js on lines 1532..1534
lib/xpath.js on lines 1556..1558
lib/xpath.js on lines 1580..1582
lib/xpath.js on lines 1604..1606
lib/xpath.js on lines 1628..1630

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 70.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 6 locations. Consider refactoring.
Open

MinusOperation.prototype.evaluate = function(c) {
    return this.lhs.evaluate(c).number().minus(this.rhs.evaluate(c).number());
};
Severity: Major
Found in lib/xpath.js and 5 other locations - About 1 hr to fix
lib/xpath.js on lines 1508..1510
lib/xpath.js on lines 1556..1558
lib/xpath.js on lines 1580..1582
lib/xpath.js on lines 1604..1606
lib/xpath.js on lines 1628..1630

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 70.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 6 locations. Consider refactoring.
Open

BarOperation.prototype.evaluate = function(c) {
    return this.lhs.evaluate(c).nodeset().union(this.rhs.evaluate(c).nodeset());
};
Severity: Major
Found in lib/xpath.js and 5 other locations - About 1 hr to fix
lib/xpath.js on lines 1508..1510
lib/xpath.js on lines 1532..1534
lib/xpath.js on lines 1556..1558
lib/xpath.js on lines 1580..1582
lib/xpath.js on lines 1604..1606

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 70.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

        Similar blocks of code found in 9 locations. Consider refactoring.
        Open

        ModOperation.prototype.toString = function() {
            return "(" + this.lhs.toString() + " mod " + this.rhs.toString() + ")";
        };
        Severity: Major
        Found in lib/xpath.js and 8 other locations - About 1 hr to fix
        lib/xpath.js on lines 1416..1418
        lib/xpath.js on lines 1440..1442
        lib/xpath.js on lines 1464..1466
        lib/xpath.js on lines 1488..1490
        lib/xpath.js on lines 1512..1514
        lib/xpath.js on lines 1536..1538
        lib/xpath.js on lines 1560..1562
        lib/xpath.js on lines 1584..1586

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 63.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 9 locations. Consider refactoring.
        Open

        LessThanOrEqualOperation.prototype.toString = function() {
            return "(" + this.lhs.toString() + " <= " + this.rhs.toString() + ")";
        };
        Severity: Major
        Found in lib/xpath.js and 8 other locations - About 1 hr to fix
        lib/xpath.js on lines 1416..1418
        lib/xpath.js on lines 1440..1442
        lib/xpath.js on lines 1488..1490
        lib/xpath.js on lines 1512..1514
        lib/xpath.js on lines 1536..1538
        lib/xpath.js on lines 1560..1562
        lib/xpath.js on lines 1584..1586
        lib/xpath.js on lines 1608..1610

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 63.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        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

          Similar blocks of code found in 9 locations. Consider refactoring.
          Open

          GreaterThanOperation.prototype.toString = function() {
              return "(" + this.lhs.toString() + " > " + this.rhs.toString() + ")";
          };
          Severity: Major
          Found in lib/xpath.js and 8 other locations - About 1 hr to fix
          lib/xpath.js on lines 1416..1418
          lib/xpath.js on lines 1464..1466
          lib/xpath.js on lines 1488..1490
          lib/xpath.js on lines 1512..1514
          lib/xpath.js on lines 1536..1538
          lib/xpath.js on lines 1560..1562
          lib/xpath.js on lines 1584..1586
          lib/xpath.js on lines 1608..1610

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 63.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 9 locations. Consider refactoring.
          Open

          MultiplyOperation.prototype.toString = function() {
              return "(" + this.lhs.toString() + " * " + this.rhs.toString() + ")";
          };
          Severity: Major
          Found in lib/xpath.js and 8 other locations - About 1 hr to fix
          lib/xpath.js on lines 1416..1418
          lib/xpath.js on lines 1440..1442
          lib/xpath.js on lines 1464..1466
          lib/xpath.js on lines 1488..1490
          lib/xpath.js on lines 1512..1514
          lib/xpath.js on lines 1536..1538
          lib/xpath.js on lines 1584..1586
          lib/xpath.js on lines 1608..1610

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 63.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Severity
          Category
          Status
          Source
          Language