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)
}
|