/**
* Calculates the complexity factors of each CodeLine
* @param astNode // The AstNode of the method
* @param startedUncommentedLines // Param for recursion (checks if the current line is the first uncommented one)
*/
private setCpxFactorsToDisplayedCode(astNode: AstNode, startedUncommentedLines = false): void { // ---------------------------- +2.6 Complexity index (+0.6 atomic, +2 recursivity)
for (const childAst of astNode.children) { // ----------------------------------------------------------------------------- +1.4 Complexity index (+0.4 atomic, +1 structural)
let issue = Math.max(childAst.lineStart, this.codeLines[0]?.issue); // ------------------------------------------------ +2.0 Complexity index (+1.0 atomic, +1 structural)
const codeLine: CodeLine = this._displayedCode.lines.find(l => l.issue === issue); // --------------------------------- +3.8 Complexity index (+1.3 atomic, +0.5 nesting, +2 structural)
if (Ast.isElseStatement(childAst)) { // ------------------------------------------------------------------------------- +2.9 Complexity index (+0.4 atomic, +0.5 nesting, +2 structural)
childAst.cpxFactors.atomic.node = cpxFactors.atomic.node; // ------------------------------------------------------ +0.8 Complexity index (+0.8 atomic)
issue--; // ------------------------------------------------------------------------------------------------------- +0.1 Complexity index (+0.1 atomic)
}
this.increaseLineCpxFactors(childAst, codeLine); // ------------------------------------------------------------------- +1.4 Complexity index (+0.4 atomic, +1 structural)
this._displayedCode.getLine(issue).astNodes.push(childAst); // -------------------------------------------------------- +2.7 Complexity index (+0.7 atomic, +2 structural)
this.setCpxFactorsToDisplayedCode(childAst, startedUncommentedLines); // ---------------------------------------------- +1.4 Complexity index (+0.4 atomic, +1 structural)
}
}
|