Genese complexity report

<- ast-file-report.service.ts
Methods : 5
Complexity index : 44.2
Cyclomatic complexity : 8
Cognitive complexity
60 % Correct 3/5
40 % Warning 2/5 (threshold : 10)
0 % Error 0/5 (threshold : 20)
Cyclomatic complexity
100 % Correct 5/5
0 % Warning 0/5 (threshold : 5)
0 % Error 0/5 (threshold : 10)
Methods of ast-file-report.service.ts
Complexity Index 0.6 Cyclomatic complexity 0
                            
                                
                
            
                constructor(astFile: AstFile) { // --------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                    this.astFile = astFile; // ------------------------------------------------------------------- +0.4 Complexity index (+0.4 atomic)
                }
            
                            
                        
getMethodsArray Complexity Index 8.1 Cyclomatic complexity 3
                            
                                
                
            
                /**
                 * Returns the array of methods with their analysis
                 */
                getMethodsArray(): MethodReport[] { // --------------------------------------- +0.3 Complexity index (+0.3 atomic)
                    let report: MethodReport[] = []; // -------------------------------------- +0.4 Complexity index (+0.4 atomic)
                    for (const method of this.astFile.astMethods) { // ----------------------- +1.5 Complexity index (+0.5 atomic, +1 structural)
                        const methodReport: MethodReport = { // ------------------------------ +0.3 Complexity index (+0.3 atomic)
                            code: method.displayedCode?.text, // ----------------------------- +0.4 Complexity index (+0.4 atomic)
                            cognitiveColor: method.cognitiveStatus.toLowerCase(), // --------- +1.4 Complexity index (+0.4 atomic, +1 structural)
                            cpxIndex: method.cpxIndex, // ------------------------------------ +0.3 Complexity index (+0.3 atomic)
                            cyclomaticColor: method.cyclomaticStatus.toLowerCase(), // ------- +1.4 Complexity index (+0.4 atomic, +1 structural)
                            cyclomaticValue: method.cyclomaticCpx, // ------------------------ +0.3 Complexity index (+0.3 atomic)
                            methodName: method.name, // -------------------------------------- +0.3 Complexity index (+0.3 atomic)
                        };
                        report.push(methodReport); // ---------------------------------------- +1.3 Complexity index (+0.3 atomic, +1 structural)
                    }
                    return report; // -------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                }
            
                            
                        
generateReport Complexity Index 16.2 Cyclomatic complexity 2
                            
                                
                
            
                /**
                 * Generates the file's report
                 */
                generateReport(): void { // -------------------------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                    this.methodReports = this.getMethodsArray(); // -------------------------------------------------------------------------------------------------------------------- +1.5 Complexity index (+0.5 atomic, +1 structural)
                    this.relativeRootReports = getRouteToRoot(this.astFile.astFolder?.relativePath); // -------------------------------------------------------------------------------- +1.8 Complexity index (+0.8 atomic, +1 structural)
                    this.registerPartial("cognitiveBarchartScript", 'cognitive-barchart'); // ------------------------------------------------------------------------------------------ +1.4 Complexity index (+0.4 atomic, +1 structural)
                    this.registerPartial("cyclomaticBarchartScript", 'cyclomatic-barchart'); // ---------------------------------------------------------------------------------------- +1.4 Complexity index (+0.4 atomic, +1 structural)
                    this.registerPartial("cognitiveDoughnutScript", 'cognitive-doughnut'); // ------------------------------------------------------------------------------------------ +1.4 Complexity index (+0.4 atomic, +1 structural)
                    this.registerPartial("cyclomaticDoughnutScript", 'cyclomatic-doughnut'); // ---------------------------------------------------------------------------------------- +1.4 Complexity index (+0.4 atomic, +1 structural)
                    this.registerPartial("method", 'methods'); // ---------------------------------------------------------------------------------------------------------------------- +1.4 Complexity index (+0.4 atomic, +1 structural)
                    const reportTemplate = eol.auto(fs.readFileSync(`${Options.pathGeneseNodeJs}/json-ast-to-reports/templates/handlebars/file-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)
                }
            
                            
                        
writeReport Complexity Index 14.3 Cyclomatic complexity 2
                            
                                
                
            
                /**
                 * Creates the file of the report
                 */
                private writeReport() { // ----------------------------------------------------------- +0.1 Complexity index (+0.1 atomic)
                    const template = this.template({ // ---------------------------------------------- +1.4 Complexity index (+0.4 atomic, +1 structural)
                        colors: Options.colors, // --------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                        methods: this.methodReports, // ---------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                        relativeRootReports: getPathWithDotSlash(this.relativeRootReports), // ------- +1.4 Complexity index (+0.4 atomic, +1 structural)
                        stats: this.astFile.stats, // ------------------------------------------------ +0.4 Complexity index (+0.4 atomic)
                        thresholds: Options.getThresholds() // --------------------------------------- +1.3 Complexity index (+0.3 atomic, +1 structural)
                    });
                    const filenameWithoutExtension = getFilenameWithoutExtension( // ----------------- +1.3 Complexity index (+0.3 atomic, +1 structural)
                        this.astFile.name // --------------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                    );
                    const RELATIVE_PATH = constructLink( // ------------------------------------------ +1.3 Complexity index (+0.3 atomic, +1 structural)
                        this.astFile.astFolder?.relativePath // -------------------------------------- +0.4 Complexity index (+0.4 atomic)
                    );
                    const OUT_DIR = constructLink(Options.pathOutDir); // ---------------------------- +1.5 Complexity index (+0.5 atomic, +1 structural)
                    let pathReport = `${deleteLastSlash(OUT_DIR)}/${deleteLastSlash( // -------------- +2.5 Complexity index (+0.5 atomic, +2 structural)
                        RELATIVE_PATH // ------------------------------------------------------------- +0.1 Complexity index (+0.1 atomic)
                    )}/${filenameWithoutExtension}.html`; // ----------------------------------------- +0.1 Complexity index (+0.1 atomic)
            
            
                    fs.writeFileSync(pathReport, template, { encoding: 'utf-8' }); // ---------------- +1.6 Complexity index (+0.6 atomic, +1 structural)
                }
            
                            
                        
registerPartial Complexity Index 5 Cyclomatic complexity 1
                            
                                
                
            
                /**
                 * Registers a HandleBar's partial for a given partial's name and a given filename
                 * @param partialName   // The name of the partial
                 * @param filename      // The name of the file
                 */
                private registerPartial(partialName: string, filename: string): void { // --------------------------------------------------------------------------------------- +0.6 Complexity index (+0.6 atomic)
                    const partial = eol.auto(fs.readFileSync(`${Options.pathGeneseNodeJs}/json-ast-to-reports/templates/handlebars/${filename}.handlebars`, 'utf-8')); // ------- +3.0 Complexity index (+1.0 atomic, +2 structural)
                    Handlebars.registerPartial(partialName, partial); // -------------------------------------------------------------------------------------------------------- +1.4 Complexity index (+0.4 atomic, +1 structural)
                }