Genese complexity report

<- ast-file-generation-java.service.ts
Methods : 1
Complexity index : 19.4
Cyclomatic complexity : 15
Cognitive complexity
0 % Correct 0/1
100 % Warning 1/1 (threshold : 10)
0 % Error 0/1 (threshold : 20)
Cyclomatic complexity
0 % Correct 0/1
0 % Warning 0/1 (threshold : 5)
100 % Error 1/1 (threshold : 10)
Methods of ast-file-generation-java.service.ts
generate Complexity Index 19.4 Cyclomatic complexity 15
                            
                                
            
            
                /**
                 * Generates the AstFile corresponding to a given path and a given AstFolder
                 * @param  {string} path
                 * @param  {AstFolderInterface} astFolder
                 * @returns AstFileInterface
                 */
                generate(path: string, astFolder: AstFolderInterface): AstFileInterface { // ------------------------------------------------------------------------- +0.6 Complexity index (+0.6 atomic)
                    if (!path || !astFolder) { // -------------------------------------------------------------------------------------------------------------------- +2.5 Complexity index (+0.5 atomic, +2 structural)
                        console.warn('No path or AstFolder : impossible to create AstFile'); // ---------------------------------------------------------------------- +1.3 Complexity index (+0.3 atomic, +1 structural)
                        return undefined; // ------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                    }
                    const fileContent = fs.readFileSync(path, 'utf8'); // -------------------------------------------------------------------------------------------- +1.6 Complexity index (+0.6 atomic, +1 structural)
                    const cst = parse(fileContent) // ---------------------------------------------------------------------------------------------------------------- +1.4 Complexity index (+0.4 atomic, +1 structural)
                    let classDeclaration = cst.children.ordinaryCompilationUnit[0].children?.typeDeclaration?.[0]?.children?.classDeclaration?.[0]; // --------------- +1.2 Complexity index (+1.2 atomic)
                    let interfaceDeclaration = cst.children.ordinaryCompilationUnit[0].children?.typeDeclaration?.[0]?.children?.interfaceDeclaration?.[0]; // ------- +1.2 Complexity index (+1.2 atomic)
                    let ast: any = []; // ---------------------------------------------------------------------------------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                    if(classDeclaration) { // ------------------------------------------------------------------------------------------------------------------------ +1.2 Complexity index (+0.2 atomic, +1 structural)
                        ast = cstToAst(classDeclaration); // --------------------------------------------------------------------------------------------------------- +1.4 Complexity index (+0.4 atomic, +1 structural)
                    } else if(interfaceDeclaration) { // ------------------------------------------------------------------------------------------------------------- +1.2 Complexity index (+0.2 atomic, +1 structural)
                        ast = cstToAst(interfaceDeclaration); // ----------------------------------------------------------------------------------------------------- +1.4 Complexity index (+0.4 atomic, +1 structural)
                    }
                    return { // -------------------------------------------------------------------------------------------------------------------------------------- +0.1 Complexity index (+0.1 atomic)
                        name: getFilename(path), // ------------------------------------------------------------------------------------------------------------------ +1.3 Complexity index (+0.3 atomic, +1 structural)
                        text: fileContent, // ------------------------------------------------------------------------------------------------------------------------ +0.2 Complexity index (+0.2 atomic)
                        astNode: { // -------------------------------------------------------------------------------------------------------------------------------- +0.1 Complexity index (+0.1 atomic)
                            kind: 'SourceFile', // ------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                            start: 0, // ----------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                            pos: 0, // ------------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                            end: fileContent.length, // -------------------------------------------------------------------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                            children: [ // --------------------------------------------------------------------------------------------------------------------------- +0.1 Complexity index (+0.1 atomic)
                                ast, // ------------------------------------------------------------------------------------------------------------------------------ +0.1 Complexity index (+0.1 atomic)
                                {
                                    "end": fileContent.length, // ---------------------------------------------------------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                                    "kind": "EndOfFileToken", // ----------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                                    "pos": fileContent.length, // ---------------------------------------------------------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                                    "start": fileContent.length // --------------------------------------------------------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                                }
                            ]
                        }
                    };
                }