kachkaev/humane-math

View on GitHub

Showing 71 of 138 total issues

Avoid deeply nested control flow statements.
Open

            if (stopSymbol) {
              currentArgument.pos = Pos.unite(
                  currentArgument.pos,
                  this.tokenStream.previousToken().pos
                );
Severity: Major
Found in src/core/analysis/2-syntactic/tree.js - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                if (realArgumentCount < argumentCount.min) {
                  errorPos = realArgumentCount
                      ? Pos.unite(
                          Pos.ending(treeNode.subNodes[realArgumentCount - 1].pos),
                          Pos.ending(treeNode.argumentPos)
    Severity: Major
    Found in src/core/analysis/3-semantic/validator.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                    if (e != this.COULD_NOT_CALCULATE_EXCEPTION) {
                      throw e;
                    }
      Severity: Major
      Found in src/core/calculator.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                    if (this.tokenStream.currentToken().type == TokenType.COMMA
                        || this.tokenStream.currentToken().type == TokenType.SEMICOLON) {
                      // It is an error if it is a semicolon
                      if (this.tokenStream.currentToken().type == TokenType.SEMICOLON) {
                        this.errors.add(new Message(
        Severity: Major
        Found in src/core/analysis/2-syntactic/tree.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                    } else if (realArgumentCount < argumentCount) {
                      errorPos = realArgumentCount
                            ? Pos.unite(Pos.ending(
                                treeNode.subNodes[realArgumentCount - 1].pos),
                                Pos.ending(treeNode.argumentPos)
          Severity: Major
          Found in src/core/analysis/3-semantic/validator.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                        if (moveCursor) {
                          this.cursorPos = i;
                        }
            Severity: Major
            Found in src/core/analysis/1-lexical/token-stream.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                        if (!(this.tokenStream.previousToken().isErrorToken() && !this.tokenStream.previousToken().isMathOperator())
                            || this.tokenStream.previousToken().isNumber()) {
                          this.errors.add(new Message('e_syn_missing_multiply',
                              Pos.between(
                                this.tokenStream.previousToken().pos,
              Severity: Major
              Found in src/core/analysis/2-syntactic/tree.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                            if (!this.tokenStream.currentToken().isEOF()) {
                              // If the content of the parsed part of the expression
                              // is a single factor, add it as the sub-node for this expression.
                              // This is made for further semantic check of it.
                              if (currentArgument.type == TreeNodeType.SYMBOL
                Severity: Major
                Found in src/core/analysis/2-syntactic/tree.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                              if (realArgumentCount < argumentCount.min) {
                                errorPos = realArgumentCount
                                    ? Pos.unite(
                                        Pos.ending(treeNode.subNodes[realArgumentCount - 1].pos),
                                        Pos.ending(treeNode.argumentPos)
                  Severity: Major
                  Found in src/core/analysis/3-semantic/validator.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                if (this.tokenStream.currentToken().isRightBracket()) {
                                  // Get the position of the current node
                                  currentNode.pos = Pos.unite(
                                      firstNodeToken.pos,
                                      this.tokenStream.currentToken().pos
                    Severity: Major
                    Found in src/core/analysis/2-syntactic/tree.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                if (stopSymbol.isRightBracket()) {
                                  currentNode.pos = Pos.unite(
                                      firstNodeToken.pos,
                                      this.tokenStream.currentToken().pos
                                    );
                      Severity: Major
                      Found in src/core/analysis/2-syntactic/tree.js - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                    if (this.tokenStream.currentToken().isRightBracket()
                                        || this.tokenStream.currentToken().type == TokenType.COMMA
                                        || this.tokenStream.currentToken().type == TokenType.SEMICOLON) {
                                      // Check if an argument is empty and add an error if so
                                      if (currentArgument.type == TreeNodeType.EMPTY) {
                        Severity: Major
                        Found in src/core/analysis/2-syntactic/tree.js - About 45 mins to fix

                          Consider simplifying this complex logical expression.
                          Open

                                if (this.tokenStream.currentToken().isTermSign()
                                    || (this.tokenStream.currentToken().isErrorToken()
                                        && !this.tokenStream.currentToken().isStatementSign()
                                        && !this.tokenStream.currentToken().isNumber()
                                        && !this.tokenStream.currentToken().isLeftBracket() && !this.tokenStream
                          Severity: Major
                          Found in src/core/analysis/2-syntactic/tree.js - About 40 mins to fix

                            Consider simplifying this complex logical expression.
                            Open

                                    if (!nextToken
                                        || !(nextToken.isMathOperator() || nextToken.isNumber()
                                            || nextToken.isSymbol() || nextToken
                                            .isLeftBracket())
                                        && nextToken.type !== TokenType.E_REST) {
                            Severity: Major
                            Found in src/core/analysis/2-syntactic/tree.js - About 40 mins to fix

                              Consider simplifying this complex logical expression.
                              Open

                                      if (currentToken.type != TokenType.SUBTRACT
                                          && (!previousToken || !(previousToken.isMathOperator()
                                              || previousToken.isRightBracket()
                                              || previousToken.isNumber() || previousToken
                                              .isSymbol()))) {
                              Severity: Major
                              Found in src/core/analysis/2-syntactic/tree.js - About 40 mins to fix

                                Function skipSpaces has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  skipSpaces() {
                                    for (var i = 0; i < this.temp.raw.length; i++) {
                                      if (this.temp.raw.charAt(i) == '\n') {
                                        this.temp.row++;
                                        this.temp.pos++;
                                Severity: Minor
                                Found in src/core/analysis/1-lexical/token-stream.js - About 35 mins 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

                                Avoid too many return statements within this function.
                                Open

                                        return currentNode;
                                Severity: Major
                                Found in src/core/analysis/2-syntactic/tree.js - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                            return NaN;
                                  Severity: Major
                                  Found in src/core/calculator.js - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                            return;
                                    Severity: Major
                                    Found in src/core/analysis/3-semantic/validator.js - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                              return;
                                      Severity: Major
                                      Found in src/core/analysis/3-semantic/validator.js - About 30 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language