ContentMine/thresher

View on GitHub

Showing 227 of 227 total issues

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

PlusOperation.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 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

GreaterThanOrEqualOperation.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 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

LessThanOperation.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 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
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

MinusOperation.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 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

DivOperation.prototype.toString = function() {
    return "(" + this.lhs.toString() + " div " + 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 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 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

    Identical blocks of code found in 2 locations. Consider refactoring.
    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 and 1 other location - About 1 hr to fix
    lib/xpath.js on lines 1886..1890

    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 61.

    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 4 locations. Consider refactoring.
    Open

    OrOperation.prototype.toString = function() {
        return "(" + this.lhs.toString() + " or " + this.rhs.toString() + ")";
    };
    Severity: Major
    Found in lib/xpath.js and 3 other locations - About 1 hr to fix
    lib/xpath.js on lines 1336..1338
    lib/xpath.js on lines 1364..1366
    lib/xpath.js on lines 1388..1390

    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 61.

    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 4 locations. Consider refactoring.
    Open

    EqualsOperation.prototype.toString = function() {
        return "(" + this.lhs.toString() + " = " + this.rhs.toString() + ")";
    };
    Severity: Major
    Found in lib/xpath.js and 3 other locations - About 1 hr to fix
    lib/xpath.js on lines 1308..1310
    lib/xpath.js on lines 1336..1338
    lib/xpath.js on lines 1388..1390

    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 61.

    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

    Identical blocks of code found in 2 locations. Consider refactoring.
    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 and 1 other location - About 1 hr to fix
    lib/xpath.js on lines 1724..1728

    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 61.

    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 4 locations. Consider refactoring.
    Open

    AndOperation.prototype.toString = function() {
        return "(" + this.lhs.toString() + " and " + this.rhs.toString() + ")";
    };
    Severity: Major
    Found in lib/xpath.js and 3 other locations - About 1 hr to fix
    lib/xpath.js on lines 1308..1310
    lib/xpath.js on lines 1364..1366
    lib/xpath.js on lines 1388..1390

    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 61.

    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 4 locations. Consider refactoring.
    Open

    NotEqualOperation.prototype.toString = function() {
        return "(" + this.lhs.toString() + " != " + this.rhs.toString() + ")";
    };
    Severity: Major
    Found in lib/xpath.js and 3 other locations - About 1 hr to fix
    lib/xpath.js on lines 1308..1310
    lib/xpath.js on lines 1336..1338
    lib/xpath.js on lines 1364..1366

    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 61.

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

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

    Functions.last = function() {
        var c = arguments[0];
        if (arguments.length != 1) {
            throw new Error("Function last expects ()");
        }
    Severity: Major
    Found in lib/xpath.js and 1 other location - About 1 hr to fix
    lib/xpath.js on lines 3287..3293

    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 60.

    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

    Functions.position = function() {
        var c = arguments[0];
        if (arguments.length != 1) {
            throw new Error("Function position expects ()");
        }
    Severity: Major
    Found in lib/xpath.js and 1 other location - About 1 hr to fix
    lib/xpath.js on lines 3279..3285

    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 60.

    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 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
            Severity
            Category
            Status
            Source
            Language