ContentMine/thresher

View on GitHub

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

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

            return c >= 0x0041 && c <= 0x005A ||
                c >= 0x0061 && c <= 0x007A ||
                c >= 0x00C0 && c <= 0x00D6 ||
                c >= 0x00D8 && c <= 0x00F6 ||
                c >= 0x00F8 && c <= 0x00FF ||
        Severity: Major
        Found in lib/xpath.js and 1 other location - About 1 day to fix
        lib/xpath.js on lines 3888..3904

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

        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

            return c >= 0x0030 && c <= 0x0039 
                || c >= 0x0660 && c <= 0x0669 
                || c >= 0x06F0 && c <= 0x06F9 
                || c >= 0x0966 && c <= 0x096F 
                || c >= 0x09E6 && c <= 0x09EF 
        Severity: Major
        Found in lib/xpath.js and 1 other location - About 1 day to fix
        lib/xpath.js on lines 3680..3696

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

        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 (last != XPathParser.AT
                                && last != XPathParser.DOUBLECOLON
                                && last != XPathParser.LEFTPARENTHESIS
                                && last != XPathParser.LEFTBRACKET
                                && last != XPathParser.AND
        Severity: Major
        Found in lib/xpath.js and 1 other location - About 1 day to fix
        lib/xpath.js on lines 1014..1054

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

        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 (last != XPathParser.AT
                                && last != XPathParser.DOUBLECOLON
                                && last != XPathParser.LEFTPARENTHESIS
                                && last != XPathParser.LEFTBRACKET
                                && last != XPathParser.AND
        Severity: Major
        Found in lib/xpath.js and 1 other location - About 1 day to fix
        lib/xpath.js on lines 912..936

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

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

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

            AVLTree.prototype.rotateLL = function() {
                // the left side is too long => rotate from the left (_not_ leftwards)
                var nodeBefore = this.node;
                var rightBefore = this.right;
                this.node = this.left.node;
            Severity: Major
            Found in lib/xpath.js and 1 other location - About 6 hrs to fix
            lib/xpath.js on lines 2729..2741

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

            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

            AVLTree.prototype.rotateRR = function() {
                // the right side is too long => rotate from the right (_not_ rightwards)
                var nodeBefore = this.node;
                var leftBefore = this.left;
                this.node = this.right.node;
            Severity: Major
            Found in lib/xpath.js and 1 other location - About 6 hrs to fix
            lib/xpath.js on lines 2715..2727

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

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

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

                XNodeSet.prototype.greaterthanorequal = function(r) {
                    if (Utilities.instance_of(r, XString)) {
                        return this.compareWithNumber(r.number(), Operators.greaterthanorequal);
                    }
                    if (Utilities.instance_of(r, XNumber)) {
                Severity: Major
                Found in lib/xpath.js and 3 other locations - About 5 hrs to fix
                lib/xpath.js on lines 3034..3045
                lib/xpath.js on lines 3047..3058
                lib/xpath.js on lines 3060..3071

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

                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

                XNodeSet.prototype.lessthan = function(r) {
                    if (Utilities.instance_of(r, XString)) {
                        return this.compareWithNumber(r.number(), Operators.lessthan);
                    }
                    if (Utilities.instance_of(r, XNumber)) {
                Severity: Major
                Found in lib/xpath.js and 3 other locations - About 5 hrs to fix
                lib/xpath.js on lines 3047..3058
                lib/xpath.js on lines 3060..3071
                lib/xpath.js on lines 3073..3084

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

                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