src/lexer.js

Summary

Maintainability
F
3 days
Test Coverage

Function Lexer has a Cognitive Complexity of 94 (exceeds 5 allowed). Consider refactoring.
Open

function Lexer(defunct) {
    if (typeof defunct !== "function"){
        defunct = function (char) {
            throw new TypeError("Unexpected character at index " + (this.index - 1) + ": " + char);
        };
Severity: Minor
Found in src/lexer.js - About 1 day 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 Lexer has 118 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function Lexer(defunct) {
    if (typeof defunct !== "function"){
        defunct = function (char) {
            throw new TypeError("Unexpected character at index " + (this.index - 1) + ": " + char);
        };
Severity: Major
Found in src/lexer.js - About 4 hrs to fix

    Function lex has 47 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        this.lex = function () {
            if (tokens.length) return tokens.shift();
    
            this.reject = true;
    
    
    Severity: Minor
    Found in src/lexer.js - About 1 hr to fix

      Function scan has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function scan() {
              /*jshint validthis: true */
              var that = this;
              var matches = [];
              var index = 0;
      Severity: Minor
      Found in src/lexer.js - About 1 hr to fix

        Avoid deeply nested control flow statements.
        Open

                                switch (Object.prototype.toString.call(token)) {
                                    case "[object Array]":
                                        tokens = token.slice(1);
                                        token = token[0];
                                        break;
        Severity: Major
        Found in src/lexer.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if (matches[j].length > matches[k].length) {
                                      var temple = matches[j];
                                      matches[j] = matches[k];
                                      matches[k] = temple;
                                  }
          Severity: Major
          Found in src/lexer.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if (Object.prototype.toString.call(token2) === "[object Array]") {
                                        tokens = token2.slice(1);
                                        return token2[0];
                                    } else return token2;
            Severity: Major
            Found in src/lexer.js - About 45 mins to fix

              There are no issues that match your filters.

              Category
              Status