Function llDriver
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
private llDriver(tokenList: IToken[], parse: boolean): unknown {
if (tokenList.length === 0) {
throw new ParserException('Token list is empty');
}
- Read upRead up
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 llDriver
has 85 lines of code (exceeds 25 allowed). Consider refactoring. Open
private llDriver(tokenList: IToken[], parse: boolean): unknown {
if (tokenList.length === 0) {
throw new ParserException('Token list is empty');
}
Avoid deeply nested control flow statements. Open
} else if (symbolX === tokenAsSymbol) {
// console.log(`Matched token/symbol ${X}`);
if (parse) {
this.grammar.pushTokenOntoSemanticStack(
Avoid deeply nested control flow statements. Open
for (let i = p.rhs.length - 1; i >= 0; --i) {
if ((p.rhs[i] as GrammarSymbol) !== GrammarSymbol.Lambda) {
// Push semantic actions, and any symbols except Lambda.
parseStack.push(p.rhs[i]);
}
Function fillParseTable
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private fillParseTable(): ReadonlyMap<string, IProduction> {
const parseTable = new Map<string, IProduction>();
for (const p of this.grammar.productions) {
const pValue = this.predict.get(p);
- Read upRead up
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 fillPredict
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private fillPredict(): ReadonlyMap<IProduction, IImmutableSet<GrammarSymbol>> {
const predict = new Map<IProduction, IImmutableSet<GrammarSymbol>>();
for (const p of this.grammar.productions) {
let s = this.computeFirst(p.getRHSWithNoSemanticActions());
- Read upRead up
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"