Genese complexity report

<- ast-folder-markdown-report.service.ts
Methods : 7
Complexity index : 44.4
Cyclomatic complexity : 11
Cognitive complexity
85.7 % Correct 6/7
14.3 % Warning 1/7 (threshold : 10)
0 % Error 0/7 (threshold : 20)
Cyclomatic complexity
100 % Correct 7/7
0 % Warning 0/7 (threshold : 5)
0 % Error 0/7 (threshold : 10)
Methods of ast-folder-markdown-report.service.ts
Complexity Index 1.2 Cyclomatic complexity 0
                            
                                
                
            
            
                constructor(astFolder: AstFolder) { // ------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                    this.astFolder = astFolder; // ----------------------------------------------------------------------------------------------------- +0.4 Complexity index (+0.4 atomic)
                    this.astFolderService.astFolder = this.astFolder; // ------------------------------------------------------------------------------- +0.6 Complexity index (+0.6 atomic)
                }
            
                            
                        
generateReport Complexity Index 7.3 Cyclomatic complexity 1
                            
                                
                
            
                /**
                 * Generates the folder's report
                 */
                generateReport(): void { // ------------------------------------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                    this.setMethodsArraySortedByDecreasingCognitiveCpx(this.astFolder); // -------------------------------------------------------------------------------------------------------- +1.4 Complexity index (+0.4 atomic, +1 structural)
                    const reportTemplate = eol.auto(fs.readFileSync(`${Options.pathGeneseNodeJs}/json-ast-to-reports/templates/handlebars/folder-markdown-report.handlebars`, 'utf-8')); // ------- +2.9 Complexity index (+0.9 atomic, +2 structural)
                    this.template = Handlebars.compile(reportTemplate); // ------------------------------------------------------------------------------------------------------------------------ +1.6 Complexity index (+0.6 atomic, +1 structural)
                    this.writeReport(); // -------------------------------------------------------------------------------------------------------------------------------------------------------- +1.2 Complexity index (+0.2 atomic, +1 structural)
                }
            
                            
                        
setMethodsArraySortedByDecreasingCognitiveCpx Complexity Index 4.7 Cyclomatic complexity 1
                            
                                
                
            
                /**
                 * Set the array of methods sorted by decreasing cognitive complexity
                 * @param astFolder    // The AstFolder to analyse
                 */
                private setMethodsArraySortedByDecreasingCognitiveCpx(astFolder: AstFolder): void { // ------------------------- +0.4 Complexity index (+0.4 atomic)
                    this.setTsFileReport(astFolder); // ------------------------------------------------------------------------ +1.3 Complexity index (+0.3 atomic, +1 structural)
                    this.setMethodsArrayReport(astFolder); // ------------------------------------------------------------------ +1.3 Complexity index (+0.3 atomic, +1 structural)
                    this.methodsArrayReport = AstMethodService.sortByDecreasingCognitiveCpx(this.methodsArrayReport); // ------- +1.7 Complexity index (+0.7 atomic, +1 structural)
                }
            
                            
                        
setMethodsArrayReport Complexity Index 6.4 Cyclomatic complexity 2
                            
                                
                
            
                /**
                 * Recursion setting the array of methods reports of each subFolder
                 * @param astFolder    // The AstFolder to analyse
                 */
                private setMethodsArrayReport(astFolder: AstFolder): void { // --------------- +2.4 Complexity index (+0.4 atomic, +2 recursivity)
                    for (const subFolder of astFolder.children) { // ------------------------- +1.4 Complexity index (+0.4 atomic, +1 structural)
                        this.setTsFileReport(subFolder); // ---------------------------------- +1.3 Complexity index (+0.3 atomic, +1 structural)
                        this.setMethodsArrayReport(subFolder); // ---------------------------- +1.3 Complexity index (+0.3 atomic, +1 structural)
                    }
                }
            
                            
                        
setTsFileReport Complexity Index 3.1 Cyclomatic complexity 2
                            
                                
                
            
                /**
                 * Recursion setting the array of methods reports of each subFolder's files
                 * @param astFolder    // The AstFolder to analyse
                 */
                private setTsFileReport(astFolder: AstFolder): void{ // ------------------------------ +0.4 Complexity index (+0.4 atomic)
                    for (const tsFile of astFolder.astFiles){ // ------------------------------------- +1.4 Complexity index (+0.4 atomic, +1 structural)
                        this.setAstMethodReport(tsFile) // ------------------------------------------- +1.3 Complexity index (+0.3 atomic, +1 structural)
                    }
                }
            
                            
                        
setAstMethodReport Complexity Index 7.3 Cyclomatic complexity 2
                            
                                
                
            
                /**
                 * Recursion setting the array of methods reports of each file's methods
                 * @param astFile    // The AstFile to analyse
                 */
                private setAstMethodReport(astFile: AstFile): void{ // ---------------------------- +0.4 Complexity index (+0.4 atomic)
                    for (const astMethod of astFile.astMethods) { // ------------------------------ +1.4 Complexity index (+0.4 atomic, +1 structural)
                        this.methodsArrayReport.push({ // ----------------------------------------- +1.3 Complexity index (+0.3 atomic, +1 structural)
                            cognitiveColor: astMethod.cognitiveStatus.toLowerCase(), // ----------- +1.4 Complexity index (+0.4 atomic, +1 structural)
                            cpxIndex: astMethod.cpxIndex, // -------------------------------------- +0.3 Complexity index (+0.3 atomic)
                            cyclomaticColor: astMethod.cyclomaticStatus.toLowerCase(), // --------- +1.4 Complexity index (+0.4 atomic, +1 structural)
                            cyclomaticValue: astMethod.cyclomaticCpx, // -------------------------- +0.3 Complexity index (+0.3 atomic)
                            filename: astFile.name, // -------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                            linkFile: undefined, // ----------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                            methodName: astMethod.name // ----------------------------------------- +0.3 Complexity index (+0.3 atomic)
                        })
                    }
                }
            
                            
                        
writeReport Complexity Index 14.4 Cyclomatic complexity 3
                            
                                
                
            
                /**
                 * Fills the HandleBar's template
                 */
                private writeReport() { // --------------------------------------------------------- +0.1 Complexity index (+0.1 atomic)
                    const template = this.template({ // -------------------------------------------- +1.4 Complexity index (+0.4 atomic, +1 structural)
                        rowFile: this.methodsArrayReport, // --------------------------------------- +0.3 Complexity index (+0.3 atomic)
                    });
                    if (this.astFolder.relativePath) { // ------------------------------------------ +1.4 Complexity index (+0.4 atomic, +1 structural)
                        createRelativeDir(this.astFolder.relativePath); // ------------------------- +1.4 Complexity index (+0.4 atomic, +1 structural)
                    }
                    const pathOutDir = constructLink(Options.pathOutDir); // ----------------------- +1.5 Complexity index (+0.5 atomic, +1 structural)
                    const relativePath = constructLink(this.astFolder.relativePath); // ------------ +1.6 Complexity index (+0.6 atomic, +1 structural)
                    const pathReport = `${deleteLastSlash(pathOutDir)}/${deleteLastSlash( // ------- +2.5 Complexity index (+0.5 atomic, +2 structural)
                        relativePath // ------------------------------------------------------------ +0.1 Complexity index (+0.1 atomic)
                    )}/folder-report.md`;
                    try {
                        fs.writeFileSync(pathReport, template, { encoding: "utf-8" }); // ---------- +1.6 Complexity index (+0.6 atomic, +1 structural)
                    } catch (err) { // ------------------------------------------------------------- +1.2 Complexity index (+0.2 atomic, +1 structural)
                        console.log(err); // ------------------------------------------------------- +1.3 Complexity index (+0.3 atomic, +1 structural)
                    }
                }