tom-weatherhead/thaw-parser

View on GitHub
src/parser-base.ts

Summary

Maintainability
D
1 day
Test Coverage

Function fillFollowSet has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

    protected fillFollowSet(): void {
        // this.grammar.nonTerminals.for Each((A: GrammarSymbol) => {
        for (const A of this.grammar.nonTerminals) {
            this.followSet.set(A, createSet<GrammarSymbol>());
        }
Severity: Minor
Found in src/parser-base.ts - About 4 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 computeFirst has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    protected computeFirst(alpha: GrammarSymbol[]): ISet<GrammarSymbol> {
        const k = alpha.length;
        const result = createSet<GrammarSymbol>();

        if (k === 0 || (k === 1 && alpha[0] === GrammarSymbol.Lambda)) {
Severity: Minor
Found in src/parser-base.ts - About 2 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 fillFirstSet has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    protected fillFirstSet(): void {
        for (const A of this.grammar.nonTerminals) {
            const s = createSet<GrammarSymbol>();

            if (this.derivesLambda.contains(A)) {
Severity: Minor
Found in src/parser-base.ts - About 2 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 fillFollowSet has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected fillFollowSet(): void {
        // this.grammar.nonTerminals.for Each((A: GrammarSymbol) => {
        for (const A of this.grammar.nonTerminals) {
            this.followSet.set(A, createSet<GrammarSymbol>());
        }
Severity: Minor
Found in src/parser-base.ts - About 1 hr to fix

    Function computeFirst has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected computeFirst(alpha: GrammarSymbol[]): ISet<GrammarSymbol> {
            const k = alpha.length;
            const result = createSet<GrammarSymbol>();
    
            if (k === 0 || (k === 1 && alpha[0] === GrammarSymbol.Lambda)) {
    Severity: Minor
    Found in src/parser-base.ts - About 1 hr to fix

      Function fillFirstSet has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected fillFirstSet(): void {
              for (const A of this.grammar.nonTerminals) {
                  const s = createSet<GrammarSymbol>();
      
                  if (this.derivesLambda.contains(A)) {
      Severity: Minor
      Found in src/parser-base.ts - About 1 hr to fix

        Function markLambda has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            private markLambda(): void {
                let changes: boolean;
        
                do {
                    changes = false;
        Severity: Minor
        Found in src/parser-base.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

        There are no issues that match your filters.

        Category
        Status