ContentMine/thresher

View on GitHub

Showing 227 of 227 total issues

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

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

    EqualsOperation.prototype.evaluate = function(c) {
        return this.lhs.evaluate(c).equals(this.rhs.evaluate(c));
    };
    Severity: Major
    Found in lib/xpath.js and 1 other location - About 1 hr to fix
    lib/xpath.js on lines 1392..1394

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

    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

    NotEqualOperation.prototype.evaluate = function(c) {
        return this.lhs.evaluate(c).notequal(this.rhs.evaluate(c));
    };
    Severity: Major
    Found in lib/xpath.js and 1 other location - About 1 hr to fix
    lib/xpath.js on lines 1368..1370

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

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

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

            GreaterThanOperation.prototype.evaluate = function(c) {
                return this.lhs.evaluate(c).greaterthan(this.rhs.evaluate(c));
            };
            Severity: Major
            Found in lib/xpath.js and 3 other locations - About 1 hr to fix
            lib/xpath.js on lines 1412..1414
            lib/xpath.js on lines 1460..1462
            lib/xpath.js on lines 1484..1486

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

            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

            LessThanOrEqualOperation.prototype.evaluate = function(c) {
                return this.lhs.evaluate(c).lessthanorequal(this.rhs.evaluate(c));
            };
            Severity: Major
            Found in lib/xpath.js and 3 other locations - About 1 hr to fix
            lib/xpath.js on lines 1412..1414
            lib/xpath.js on lines 1436..1438
            lib/xpath.js on lines 1484..1486

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

            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

            GreaterThanOrEqualOperation.prototype.evaluate = function(c) {
                return this.lhs.evaluate(c).greaterthanorequal(this.rhs.evaluate(c));
            };
            Severity: Major
            Found in lib/xpath.js and 3 other locations - About 1 hr to fix
            lib/xpath.js on lines 1412..1414
            lib/xpath.js on lines 1436..1438
            lib/xpath.js on lines 1460..1462

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

            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

            LessThanOperation.prototype.evaluate = function(c) {
                return this.lhs.evaluate(c).lessthan(this.rhs.evaluate(c));
            };
            Severity: Major
            Found in lib/xpath.js and 3 other locations - About 1 hr to fix
            lib/xpath.js on lines 1436..1438
            lib/xpath.js on lines 1460..1462
            lib/xpath.js on lines 1484..1486

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

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

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

                      if (c == '(') {
                          types.push(XPathParser.LEFTPARENTHESIS);
                          values.push(c);
                          c = s.charAt(pos++);
                          continue;
              Severity: Major
              Found in lib/xpath.js and 10 other locations - About 1 hr to fix
              lib/xpath.js on lines 789..794
              lib/xpath.js on lines 795..800
              lib/xpath.js on lines 801..806
              lib/xpath.js on lines 807..812
              lib/xpath.js on lines 813..818
              lib/xpath.js on lines 819..824
              lib/xpath.js on lines 825..830
              lib/xpath.js on lines 831..836
              lib/xpath.js on lines 837..842
              lib/xpath.js on lines 843..848

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

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

                      if (c == '$') {
                          types.push(XPathParser.DOLLAR);
                          values.push(c);
                          c = s.charAt(pos++);
                          continue;
              Severity: Major
              Found in lib/xpath.js and 10 other locations - About 1 hr to fix
              lib/xpath.js on lines 783..788
              lib/xpath.js on lines 789..794
              lib/xpath.js on lines 795..800
              lib/xpath.js on lines 801..806
              lib/xpath.js on lines 807..812
              lib/xpath.js on lines 813..818
              lib/xpath.js on lines 819..824
              lib/xpath.js on lines 825..830
              lib/xpath.js on lines 831..836
              lib/xpath.js on lines 837..842

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

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

                      if (c == '=') {
                          types.push(XPathParser.EQUALS);
                          values.push(c);
                          c = s.charAt(pos++);
                          continue;
              Severity: Major
              Found in lib/xpath.js and 10 other locations - About 1 hr to fix
              lib/xpath.js on lines 783..788
              lib/xpath.js on lines 789..794
              lib/xpath.js on lines 795..800
              lib/xpath.js on lines 801..806
              lib/xpath.js on lines 807..812
              lib/xpath.js on lines 813..818
              lib/xpath.js on lines 819..824
              lib/xpath.js on lines 825..830
              lib/xpath.js on lines 831..836
              lib/xpath.js on lines 843..848

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

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

                      if (c == ']') {
                          types.push(XPathParser.RIGHTBRACKET);
                          values.push(c);
                          c = s.charAt(pos++);
                          continue;
              Severity: Major
              Found in lib/xpath.js and 10 other locations - About 1 hr to fix
              lib/xpath.js on lines 783..788
              lib/xpath.js on lines 789..794
              lib/xpath.js on lines 795..800
              lib/xpath.js on lines 807..812
              lib/xpath.js on lines 813..818
              lib/xpath.js on lines 819..824
              lib/xpath.js on lines 825..830
              lib/xpath.js on lines 831..836
              lib/xpath.js on lines 837..842
              lib/xpath.js on lines 843..848

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

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

                      if (c == '-') {
                          types.push(XPathParser.MINUS);
                          values.push(c);
                          c = s.charAt(pos++);
                          continue;
              Severity: Major
              Found in lib/xpath.js and 10 other locations - About 1 hr to fix
              lib/xpath.js on lines 783..788
              lib/xpath.js on lines 789..794
              lib/xpath.js on lines 795..800
              lib/xpath.js on lines 801..806
              lib/xpath.js on lines 807..812
              lib/xpath.js on lines 813..818
              lib/xpath.js on lines 819..824
              lib/xpath.js on lines 825..830
              lib/xpath.js on lines 837..842
              lib/xpath.js on lines 843..848

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

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

                      if (c == '|') {
                          types.push(XPathParser.BAR);
                          values.push(c);
                          c = s.charAt(pos++);
                          continue;
              Severity: Major
              Found in lib/xpath.js and 10 other locations - About 1 hr to fix
              lib/xpath.js on lines 783..788
              lib/xpath.js on lines 789..794
              lib/xpath.js on lines 795..800
              lib/xpath.js on lines 801..806
              lib/xpath.js on lines 807..812
              lib/xpath.js on lines 813..818
              lib/xpath.js on lines 825..830
              lib/xpath.js on lines 831..836
              lib/xpath.js on lines 837..842
              lib/xpath.js on lines 843..848

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

              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