sounisi5011/ts-peg

View on GitHub

Showing 5 of 15 total issues

File character-class.ts has 321 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { mappingCharsMap, unicodeVersion } from '../../case-folding-map';
import {
    ParseFailureResult,
    Parser,
    ParseResult,
Severity: Minor
Found in src/parser/primary/character-class.ts - About 3 hrs to fix

    Function toPattern has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        toPattern(isInverse = false): string {
            const cachedPattern = this.__patternCache.get(isInverse);
            if (this.__normalized && typeof cachedPattern === 'string') {
                return cachedPattern;
            }
    Severity: Major
    Found in src/parser/primary/character-class.ts - About 2 hrs to fix

      Function toPattern has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          toPattern(isInverse = false): string {
              const cachedPattern = this.__patternCache.get(isInverse);
              if (this.__normalized && typeof cachedPattern === 'string') {
                  return cachedPattern;
              }
      Severity: Minor
      Found in src/parser/primary/character-class.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 isMatch has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          isMatch(str: string, position = 0): string | null {
              const codePoint = str.codePointAt(position);
              if (typeof codePoint !== 'number') return null;
      
              if (this.__codePointRanges.includes(codePoint)) {
      Severity: Minor
      Found in src/parser/primary/character-class.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 i has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          get i(): CharacterClassParser {
              const newCodePointRanges = new CodePointRangeSet(
                  ...this.__codePointRanges,
              );
              for (const codePointRange of this.__codePointRanges) {
      Severity: Minor
      Found in src/parser/primary/character-class.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