Genese complexity report

<- index.ts
Methods : 2
Complexity index : 60.7
Cyclomatic complexity : 11
Cognitive complexity
0 % Correct 0/2
0 % Warning 0/2 (threshold : 10)
100 % Error 2/2 (threshold : 20)
Cyclomatic complexity
50 % Correct 1/2
50 % Warning 1/2 (threshold : 5)
0 % Error 0/2 (threshold : 10)
Methods of index.ts
start Complexity Index 39.6 Cyclomatic complexity 9
                            
                                
                
            
            async function start(): Promise<number> { // ------------------------------------------------------ +0.2 Complexity index (+0.2 atomic)
                Options.setOptions(process.cwd(), pathToAnalyse, __dirname); // ------------------------------- +2.6 Complexity index (+0.6 atomic, +2 structural)
                if (!ENABLE_CONSOLE_REPORT) { // -------------------------------------------------------------- +1.2 Complexity index (+0.2 atomic, +1 structural)
                    createOutDir(); // ------------------------------------------------------------------------ +1.1 Complexity index (+0.1 atomic, +1 structural)
                }
            
                spinner.start('AST generation'); // ----------------------------------------------------------- +1.3 Complexity index (+0.3 atomic, +1 structural)
                await useWorker( // --------------------------------------------------------------------------- +1.1 Complexity index (+0.1 atomic, +1 structural)
                    `${__dirname}/workers/ast-worker.js`, // -------------------------------------------------- +0.1 Complexity index (+0.1 atomic)
                    {
                        pathCommand: process.cwd(), // -------------------------------------------------------- +1.3 Complexity index (+0.3 atomic, +1 structural)
                        modifiedPath: pathToAnalyse, // ------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                        pathGeneseNodeJs: __dirname, // ------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                        language: LANGUAGE // ----------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                    });
                spinner.succeed(); // ------------------------------------------------------------------------- +1.2 Complexity index (+0.2 atomic, +1 structural)
            
                spinner.start('Report generation'); // -------------------------------------------------------- +1.3 Complexity index (+0.3 atomic, +1 structural)
                const reportResult: { message: any; astFolder: AstFolder } = await useWorker( // -------------- +1.7 Complexity index (+0.7 atomic, +1 structural)
                    `${__dirname}/workers/report-worker.js`, // ----------------------------------------------- +0.1 Complexity index (+0.1 atomic)
                    {
                        pathCommand: process.cwd(), // -------------------------------------------------------- +1.3 Complexity index (+0.3 atomic, +1 structural)
                        modifiedPath: pathToAnalyse, // ------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                        pathGeneseNodeJs: __dirname, // ------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                        markdown: ENABLE_MARKDOWN_REPORT, // -------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                        consoleMode: ENABLE_CONSOLE_REPORT, // ------------------------------------------------ +0.2 Complexity index (+0.2 atomic)
                    });
                spinner.succeed(); // ------------------------------------------------------------------------- +1.2 Complexity index (+0.2 atomic, +1 structural)
            
                if (LANGUAGE === Language.TS && !ENABLE_CONSOLE_REPORT && ENABLE_REFACTORING) { // ------------ +4.1 Complexity index (+1.1 atomic, +3 structural)
                    spinner.start('Refactoring generation'); // ----------------------------------------------- +1.3 Complexity index (+0.3 atomic, +1 structural)
                    await useWorker( // ----------------------------------------------------------------------- +1.1 Complexity index (+0.1 atomic, +1 structural)
                        `${__dirname}/workers/refactoring-worker.js`, // -------------------------------------- +0.1 Complexity index (+0.1 atomic)
                        {
                            pathCommand: Options.pathCommand, // ---------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                            modifiedPath: pathToAnalyse, // --------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                            pathGeneseNodeJs: __dirname, // --------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                            astFolder: reportResult.astFolder // ---------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                        });
                    spinner.succeed(); // --------------------------------------------------------------------- +1.2 Complexity index (+0.2 atomic, +1 structural)
                }
            
                deleteFile('./json-ast.json'); // ------------------------------------------------------------- +1.2 Complexity index (+0.2 atomic, +1 structural)
            
                if (reportResult.message && reportResult.message.length > 0) { // ----------------------------- +3.0 Complexity index (+1.0 atomic, +2 structural)
                    console.log(); // ------------------------------------------------------------------------- +1.2 Complexity index (+0.2 atomic, +1 structural)
                    if (typeof reportResult.message === 'object') { // ---------------------------------------- +2.0 Complexity index (+0.5 atomic, +0.5 nesting, +1 structural)
                        console.table(reportResult.message, ['filename', 'methodName', 'cpxIndex']); // ------- +1.7 Complexity index (+0.7 atomic, +1 structural)
                    } else { // ------------------------------------------------------------------------------- +1.1 Complexity index (+0.1 atomic, +1 structural)
                        console.log(reportResult.message); // ------------------------------------------------- +1.4 Complexity index (+0.4 atomic, +1 structural)
                    }
                    if (ENABLE_CONSOLE_REPORT) { // ----------------------------------------------------------- +1.7 Complexity index (+0.2 atomic, +0.5 nesting, +1 structural)
                        return 1; // -------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                    }
                }
                return 0; // ---------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
            }
            
                            
                        
useWorker Complexity Index 21.1 Cyclomatic complexity 2
                            
                                
            
            
            function useWorker(filepath, data): any { // ----------------------------------------- +0.4 Complexity index (+0.4 atomic)
                return new Promise((resolve, reject) => { // ------------------------------------- +5.6 Complexity index (+0.6 atomic, +4 recursivity, +1 structural)
                    const worker = new Worker(filepath, {workerData: data}); // ------------------ +0.7 Complexity index (+0.7 atomic)
            
                    worker.on('message', message => { // ----------------------------------------- +3.5 Complexity index (+0.5 atomic, +1 nesting, +2 structural)
                        resolve(message); // ----------------------------------------------------- +1.2 Complexity index (+0.2 atomic, +1 structural)
                    });
            
                    worker.on('error', reject); // ----------------------------------------------- +1.4 Complexity index (+0.4 atomic, +1 structural)
                    worker.on('exit', code => { // ----------------------------------------------- +3.5 Complexity index (+0.5 atomic, +1 nesting, +2 structural)
                        if (code !== 0) { // ----------------------------------------------------- +3.4 Complexity index (+0.4 atomic, +2 nesting, +1 structural)
                            reject(new Error(`Worker stopped with exit code ${code}`)); // ------- +1.4 Complexity index (+0.4 atomic, +1 structural)
                        }
                    });
                });
            }