benmarch/spel2js

View on GitHub
src/SpelExpressionParser.js

Summary

Maintainability
F
2 wks
Test Coverage

Function SpelExpressionParser has a Cognitive Complexity of 323 (exceeds 5 allowed). Consider refactoring.
Open

export var SpelExpressionParser = function () {


    var VALID_QUALIFIED_ID_PATTERN = new RegExp('[\\p{L}\\p{N}_$]+');

Severity: Minor
Found in src/SpelExpressionParser.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 SpelExpressionParser has 738 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export var SpelExpressionParser = function () {


    var VALID_QUALIFIED_ID_PATTERN = new RegExp('[\\p{L}\\p{N}_$]+');

Severity: Major
Found in src/SpelExpressionParser.js - About 3 days to fix

    File SpelExpressionParser.js has 784 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*
     * Copyright 2002-2015 the original author or authors.
     *
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
    Severity: Major
    Found in src/SpelExpressionParser.js - About 1 day to fix

      Function maybeEatInlineListOrMap has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function maybeEatInlineListOrMap() {
              var token = peekToken(),
                  listElements = [];
      
              if (!peekTokenConsumeIfMatched(TokenKind.LCURLY, true)) {
      Severity: Minor
      Found in src/SpelExpressionParser.js - About 1 hr to fix

        Function eatRelationalExpression has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function eatRelationalExpression() {
                var expr = eatSumExpression();
                var relationalOperatorToken = maybeEatRelationalOperator();
                if (relationalOperatorToken !== null) {
                    var token = nextToken();  // consume relational operator token
        Severity: Minor
        Found in src/SpelExpressionParser.js - About 1 hr to fix

          Function eatExpression has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function eatExpression() {
                  var expr = eatLogicalOrExpression();
                  if (moreTokens()) {
                      var token = peekToken();
                      if (token.getKind() === TokenKind.ASSIGN) {  // a=b
          Severity: Minor
          Found in src/SpelExpressionParser.js - About 1 hr to fix

            Function maybeEatConstructorReference has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function maybeEatConstructorReference() {
                    if (peekIdentifierToken('new')) {
                        var newToken = nextToken();
                        // It looks like a constructor reference but is NEW being used as a map key?
                        if (peekTokenOne(TokenKind.RSQUARE)) {
            Severity: Minor
            Found in src/SpelExpressionParser.js - About 1 hr to fix

              Function maybeEatLiteral has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  function maybeEatLiteral() {
                      var token = peekToken();
                      if (token === null) {
                          return false;
                      }
              Severity: Minor
              Found in src/SpelExpressionParser.js - About 1 hr to fix

                Avoid too many return statements within this function.
                Open

                                return OpMatches.create(toPosToken(token), expr, rhExpr);
                Severity: Major
                Found in src/SpelExpressionParser.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                              return null;
                  Severity: Major
                  Found in src/SpelExpressionParser.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                        return OpEQ.create(pos, expr, rhExpr);
                    Severity: Major
                    Found in src/SpelExpressionParser.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                              return expr;
                      Severity: Major
                      Found in src/SpelExpressionParser.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                return null;
                        Severity: Major
                        Found in src/SpelExpressionParser.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                      return pop();
                          Severity: Major
                          Found in src/SpelExpressionParser.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                        return pop();
                            Severity: Major
                            Found in src/SpelExpressionParser.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                          return OpDec.create(toPosToken(token), false, expr);
                              Severity: Major
                              Found in src/SpelExpressionParser.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                            return OpBetween.create(toPosToken(token), expr, rhExpr);
                                Severity: Major
                                Found in src/SpelExpressionParser.js - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                          return eatPrimaryExpression();
                                  Severity: Major
                                  Found in src/SpelExpressionParser.js - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                                    return OpNE.create(pos, expr, rhExpr);
                                    Severity: Major
                                    Found in src/SpelExpressionParser.js - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                                      return OpInstanceof.create(toPosToken(token), expr, rhExpr);
                                      Severity: Major
                                      Found in src/SpelExpressionParser.js - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                                        return token.asBetweenToken();
                                        Severity: Major
                                        Found in src/SpelExpressionParser.js - About 30 mins to fix

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

                                              function eatLogicalAndExpression() {
                                                  var expr = eatRelationalExpression();
                                                  while (peekIdentifierToken('and') || peekTokenOne(TokenKind.SYMBOLIC_AND)) {
                                                      var token = nextToken();  // consume 'AND'
                                                      var rhExpr = eatRelationalExpression();
                                          Severity: Major
                                          Found in src/SpelExpressionParser.js and 1 other location - About 3 hrs to fix
                                          src/SpelExpressionParser.js on lines 171..180

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

                                          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

                                              function eatLogicalOrExpression() {
                                                  var expr = eatLogicalAndExpression();
                                                  while (peekIdentifierToken('or') || peekTokenOne(TokenKind.SYMBOLIC_OR)) {
                                                      var token = nextToken();  //consume OR
                                                      var rhExpr = eatLogicalAndExpression();
                                          Severity: Major
                                          Found in src/SpelExpressionParser.js and 1 other location - About 3 hrs to fix
                                          src/SpelExpressionParser.js on lines 183..192

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

                                          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

                                                          if (expr === null) {
                                                              expr = NullLiteral.create(toPosBounds(token.startPos - 1, token.endPos - 2));
                                                          }
                                          Severity: Major
                                          Found in src/SpelExpressionParser.js and 2 other locations - About 40 mins to fix
                                          src/SpelExpressionParser.js on lines 136..138
                                          src/SpelExpressionParser.js on lines 157..159

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

                                          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

                                                          if (expr === null) {
                                                              expr = NullLiteral.create(toPosBounds(token.startPos - 1, token.endPos - 1));
                                                          }
                                          Severity: Major
                                          Found in src/SpelExpressionParser.js and 2 other locations - About 40 mins to fix
                                          src/SpelExpressionParser.js on lines 136..138
                                          src/SpelExpressionParser.js on lines 145..147

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

                                          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

                                                          if (expr === null) {
                                                              expr = NullLiteral.create(toPosBounds(token.startPos - 1, token.endPos - 1));
                                                          }
                                          Severity: Major
                                          Found in src/SpelExpressionParser.js and 2 other locations - About 40 mins to fix
                                          src/SpelExpressionParser.js on lines 145..147
                                          src/SpelExpressionParser.js on lines 157..159

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

                                          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

                                          There are no issues that match your filters.

                                          Category
                                          Status