3axap4eHko/xast

View on GitHub

Showing 12 of 19 total issues

Function readString has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

export const readString: Tokenizer = (lexer, start, quoteCode) => {
    const source = lexer.source;
    const body = source.body;
    const bodyLength = body.length;
    let position = start + 1;
Severity: Minor
Found in src/tokenizers/readString.ts - About 3 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

Function readString has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const readString: Tokenizer = (lexer, start, quoteCode) => {
    const source = lexer.source;
    const body = source.body;
    const bodyLength = body.length;
    let position = start + 1;
Severity: Minor
Found in src/tokenizers/readString.ts - About 1 hr to fix

    Function addDefaultTokenizers has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const addDefaultTokenizers = (lexer: Lexer) => {
    
      lexer.add(0x0023, (lexer, position, code) => readComment(lexer, position, code));
      lexer.add(0x002f, (lexer, position, code) => {
        if (lexer.source.body[position + 1].charCodeAt(0) === 0x002f) {
    Severity: Minor
    Found in src/addDefaultTokenizers.ts - About 1 hr to fix

      Function readNumber has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const readNumber: Tokenizer = (lexer, start, firstCode) => {
        const source = lexer.source;
        const body = source.body;
        let position = start;
        let code = firstCode;
      Severity: Minor
      Found in src/tokenizers/readNumber.ts - About 1 hr to fix

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

        export const readNumber: Tokenizer = (lexer, start, firstCode) => {
          const source = lexer.source;
          const body = source.body;
          let position = start;
          let code = firstCode;
        Severity: Minor
        Found in src/tokenizers/readNumber.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 getValue has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const getValue = (parser: Parser): ValueNode => {
          const token = parser.lexer.token;
          parser.advanceLexer();
          switch (token.kind) {
            case TokenKind.NUMBER:
        Severity: Minor
        Found in src/__tests__/variable.ts - About 1 hr to fix

          Function readEscapedCharacter has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            readEscapedCharacter(position: number): EscapeSequence {
              const body = this.body;
              const code = body.charCodeAt(position + 1);
              switch (code) {
                case 0x0022: // "
          Severity: Minor
          Found in src/Source.ts - About 1 hr to fix

            Function readEscapedUnicodeVariableWidth has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

              readEscapedUnicodeVariableWidth(position: number): EscapeSequence {
                const body = this.body;
                let point = 0;
                let size = 3;
                while (size < 12) {
            Severity: Minor
            Found in src/Source.ts - About 55 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

            Function readComment has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            export const readComment: Tokenizer = (lexer, start) => {
              const body = lexer.source.body;
              const bodyLength = body.length;
              let position = start + 1;
            
            
            Severity: Minor
            Found in src/tokenizers/readComment.ts - About 45 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

            Function readEscapedUnicodeFixedWidth has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              readEscapedUnicodeFixedWidth(position: number): EscapeSequence {
                const body = this.body;
                const code = read16BitHexCode(body, position + 2);
            
                if (isUnicodeScalarValue(code)) {
            Severity: Minor
            Found in src/Source.ts - About 45 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

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

              lookahead(): Token {
                let token = this.token;
                if (token.kind !== TokenKind.EOF) {
                  do {
                    if (token.next) {
            Severity: Minor
            Found in src/Lexer.ts - 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

            Function add has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              add<N extends Node>(nodeParser: NodeParser<N>): void {
                if (nodeParser.trigger) {
                  if (!this._parsersMap.has(nodeParser.trigger.kind)) {
                    this._parsersMap.set(nodeParser.trigger.kind, new Map);
                  }
            Severity: Minor
            Found in src/Parser.ts - About 25 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

            Severity
            Category
            Status
            Source
            Language