Genese complexity report

<- refactor-report.service.ts
Methods : 5
Complexity index : 28
Cyclomatic complexity : 6
Cognitive complexity
80 % Correct 4/5
20 % Warning 1/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 refactor-report.service.ts
Complexity Index 0.5 Cyclomatic complexity 0
                            
                                
                
            
                constructor(public systems: RefactorProposal[], private astFolder: AstFolder) {} // ------- +0.5 Complexity index (+0.5 atomic)
            
                            
                        
generateRefactorReport Complexity Index 9.1 Cyclomatic complexity 1
                            
                                
                
            
                /**
                 * Register partials and compile template
                 * @returns {void}
                 */
                generateRefactorReport(): void { // -------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                    this.registerPartial('refactorProposals', 'refactor-proposals'); // -------------------------------------------------------------------- +1.4 Complexity index (+0.4 atomic, +1 structural)
                    this.registerPartial('refactorComparaison', 'refactor-comparaison'); // ---------------------------------------------------------------- +1.4 Complexity index (+0.4 atomic, +1 structural)
                    this.registerPartial('methodCode', 'method-script'); // -------------------------------------------------------------------------------- +1.4 Complexity index (+0.4 atomic, +1 structural)
            
                    const TEMPLATE_PATH = `${Options.pathGeneseNodeJs}/automatic-refactoring/templates/handlebars/refactor-proposals.handlebars`; // ------- +0.4 Complexity index (+0.4 atomic)
                    const REPORT_TEMPLATE = this.getFileFromPath(TEMPLATE_PATH); // ------------------------------------------------------------------------ +1.5 Complexity index (+0.5 atomic, +1 structural)
                    this.template = Handlebars.compile(REPORT_TEMPLATE); // -------------------------------------------------------------------------------- +1.6 Complexity index (+0.6 atomic, +1 structural)
                    this.writeRefactorReport(); // --------------------------------------------------------------------------------------------------------- +1.2 Complexity index (+0.2 atomic, +1 structural)
                }
            
                            
                        
writeRefactorReport Complexity Index 11 Cyclomatic complexity 3
                            
                                
                
            
                /**
                 * Generate refactor report HTML
                 * @returns {void}
                 */
                private writeRefactorReport(): void { // ------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                    const RELATIVE_ROOT = getRouteToRoot(this.astFolder?.relativePath); // --------------------------------------------- +1.6 Complexity index (+0.6 atomic, +1 structural)
                    const TEMPLATE = this.template({ proposals: this.refactorProposals, relativeRoot: RELATIVE_ROOT }); // ------------- +1.9 Complexity index (+0.9 atomic, +1 structural)
                    const RELATIVE_PATH = constructLink(this.astFolder?.relativePath); // ---------------------------------------------- +1.6 Complexity index (+0.6 atomic, +1 structural)
                    const OUT_DIR = constructLink(Options.pathOutDir); // -------------------------------------------------------------- +1.5 Complexity index (+0.5 atomic, +1 structural)
                    const PATH_REPORT = `${deleteLastSlash(OUT_DIR)}/${deleteLastSlash(RELATIVE_PATH)}/refactor-report.html`; // ------- +2.6 Complexity index (+0.6 atomic, +2 structural)
                    fs.outputFileSync(PATH_REPORT, TEMPLATE, { encoding: 'utf-8' }); // ------------------------------------------------ +1.6 Complexity index (+0.6 atomic, +1 structural)
                }
            
                            
                        
registerPartial Complexity Index 4 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
                 * @returns {void}
                 */
                private registerPartial(partialName: string, filename: string): void { // ---------------------------------------------------------- +0.6 Complexity index (+0.6 atomic)
                    const PARTIAL_PATH = `${Options.pathGeneseNodeJs}/automatic-refactoring/templates/handlebars/${filename}.handlebars`; // ------- +0.5 Complexity index (+0.5 atomic)
                    const PARTIAL = this.getFileFromPath(PARTIAL_PATH); // ------------------------------------------------------------------------- +1.5 Complexity index (+0.5 atomic, +1 structural)
                    Handlebars.registerPartial(partialName, PARTIAL); // --------------------------------------------------------------------------- +1.4 Complexity index (+0.4 atomic, +1 structural)
                }
            
                            
                        
getFileFromPath Complexity Index 3.4 Cyclomatic complexity 1
                            
                                
                
            
                /**
                 * read file, normalize content and return it
                 * @param path the file path
                 * @returns {string}
                 */
                private getFileFromPath(path: string): string { // ---------------- +0.4 Complexity index (+0.4 atomic)
                    const FILE_CONTENT = fs.readFileSync(path, 'utf-8'); // ------- +1.6 Complexity index (+0.6 atomic, +1 structural)
                    return eol.auto(FILE_CONTENT); // ----------------------------- +1.4 Complexity index (+0.4 atomic, +1 structural)
                }