badeball/xpath-analyzer

View on GitHub

Showing 24 of 24 total issues

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

export function parse (rootParser: ExprParser, lexer: XPathLexer): ExprNode {
  var lhs = RelationalExpr.parse(rootParser, lexer);

  var equalityTypes: {
    [index:string]: typeof EQUALITY | typeof INEQUALITY
Severity: Major
Found in lib/parsers/equality_expr.ts and 1 other location - About 6 hrs to fix
lib/parsers/additive_expr.ts on lines 17..40

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

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

export function parse (rootParser: ExprParser, lexer: XPathLexer): ExprNode {
  var lhs = MultiplicativeExpr.parse(rootParser, lexer);

  var additiveTypes: {
    [index:string]: typeof ADDITIVE | typeof SUBTRACTIVE
Severity: Major
Found in lib/parsers/additive_expr.ts and 1 other location - About 6 hrs to fix
lib/parsers/equality_expr.ts on lines 17..40

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

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

  while (!lexer.empty() && lexer.peak()[0] === "/") {
    if (lexer.next() === "//") {
      relativeLocation.steps.push({
        axis: DESCENDANT_OR_SELF,
        test: {
Severity: Major
Found in lib/parsers/relative_location_path.ts and 1 other location - About 4 hrs to fix
lib/parsers/path_expr.ts on lines 36..49

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

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

      while (!lexer.empty() && lexer.peak()[0] === "/") {
        if (lexer.next() === "//") {
          path.steps.push({
            axis: DESCENDANT_OR_SELF,
            test: {
Severity: Major
Found in lib/parsers/path_expr.ts and 1 other location - About 4 hrs to fix
lib/parsers/relative_location_path.ts on lines 26..39

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

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

export function parse (rootParser: ExprParser, lexer: XPathLexer): ExprNode {
  var lhs = EqualityExpr.parse(rootParser, lexer);

  if (lexer.peak() === "and") {
    lexer.next();
Severity: Major
Found in lib/parsers/and_expr.ts and 2 other locations - About 3 hrs to fix
lib/parsers/or_expr.ts on lines 15..31
lib/parsers/union_expr.ts on lines 15..31

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

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

export function parse (rootParser: ExprParser, lexer: XPathLexer): ExprNode {
  var lhs = PathExpr.parse(rootParser, lexer);

  if (lexer.peak() === "|") {
    lexer.next();
Severity: Major
Found in lib/parsers/union_expr.ts and 2 other locations - About 3 hrs to fix
lib/parsers/and_expr.ts on lines 17..33
lib/parsers/or_expr.ts on lines 15..31

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

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

export function parse (rootParser: ExprParser, lexer: XPathLexer): ExprNode {
  var lhs = AndExpr.parse(rootParser, lexer);

  if (lexer.peak() === "or") {
    lexer.next();
Severity: Major
Found in lib/parsers/or_expr.ts and 2 other locations - About 3 hrs to fix
lib/parsers/and_expr.ts on lines 17..33
lib/parsers/union_expr.ts on lines 15..31

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

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 specifier == ANCESTOR ||
    specifier == ANCESTOR_OR_SELF ||
    specifier == ATTRIBUTE ||
    specifier == CHILD ||
    specifier == DESCENDANT ||
Severity: Major
Found in lib/validators/axis_specifier.ts and 1 other location - About 3 hrs to fix
lib/validators/function_name.ts on lines 32..44

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

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 name == BOOLEAN ||
    name == CEILING ||
    name == CONCAT ||
    name == CONTAINS ||
    name == COUNT ||
Severity: Major
Found in lib/validators/function_name.ts and 1 other location - About 3 hrs to fix
lib/validators/axis_specifier.ts on lines 19..31

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

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 parse has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

export function parse (rootParser: ExprParser, lexer: XPathLexer): NodeTestNode {
  if (lexer.peak() === "*") {
    lexer.next();

    return {
Severity: Minor
Found in lib/parsers/node_test.ts - About 2 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

export function parse (rootParser: ExprParser, lexer: XPathLexer): PredicateNode {
  lexer.next();

  var predicate = rootParser.parse(lexer);

Severity: Major
Found in lib/parsers/predicate.ts and 1 other location - About 2 hrs to fix
lib/parsers/primary_expr.ts on lines 29..41

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

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

  if (ch === "(") {
    lexer.next();

    var expr = rootParser.parse(lexer);

Severity: Major
Found in lib/parsers/primary_expr.ts and 1 other location - About 2 hrs to fix
lib/parsers/predicate.ts on lines 7..19

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

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 parse has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function parse (rootParser: ExprParser, lexer: XPathLexer): StepNode {
  if (lexer.peak() === "..") {
    lexer.next();

    return {
Severity: Minor
Found in lib/parsers/step.ts - About 1 hr to fix

    Function parse has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    export function parse (rootParser: ExprParser, lexer: XPathLexer): ExprNode {
      if (FilterExpr.isValidOp(lexer)) {
        var filter = FilterExpr.parse(rootParser, lexer);
    
        if (!lexer.empty() && lexer.peak()[0] === "/") {
    Severity: Minor
    Found in lib/parsers/path_expr.ts - 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 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function parse (rootParser: ExprParser, lexer: XPathLexer): NodeTestNode {
      if (lexer.peak() === "*") {
        lexer.next();
    
        return {
    Severity: Minor
    Found in lib/parsers/node_test.ts - About 1 hr to fix

      Function parse has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      export function parse (rootParser: ExprParser, lexer: XPathLexer): FunctionNode {
        var functionName = lexer.peak() as string;
      
        if (!isValid(functionName)) {
          throw new Error("Invalid function at position " + lexer.position());
      Severity: Minor
      Found in lib/parsers/function_call.ts - 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 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function parse (rootParser: ExprParser, lexer: XPathLexer): ExprNode {
        var token = lexer.peak(),
            ch = token && token[0];
      
        if (ch === "(") {
      Severity: Minor
      Found in lib/parsers/primary_expr.ts - About 1 hr to fix

        Function parse has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        export function parse (rootParser: ExprParser, lexer: XPathLexer): ExprNode {
          var token = lexer.peak(),
              ch = token && token[0];
        
          if (ch === "(") {
        Severity: Minor
        Found in lib/parsers/primary_expr.ts - 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 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function parse (rootParser: ExprParser, lexer: XPathLexer): FunctionNode {
          var functionName = lexer.peak() as string;
        
          if (!isValid(functionName)) {
            throw new Error("Invalid function at position " + lexer.position());
        Severity: Minor
        Found in lib/parsers/function_call.ts - About 1 hr to fix

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

          export function parse (rootParser: ExprParser, lexer: XPathLexer): ExprNode {
            if (FilterExpr.isValidOp(lexer)) {
              var filter = FilterExpr.parse(rootParser, lexer);
          
              if (!lexer.empty() && lexer.peak()[0] === "/") {
          Severity: Minor
          Found in lib/parsers/path_expr.ts - About 1 hr to fix
            Severity
            Category
            Status
            Source
            Language