Genese complexity report

<- ts.service.ts
Methods : 3
Complexity index : 32.9
Cyclomatic complexity : 14
Cognitive complexity
66.7 % Correct 2/3
33.3 % Warning 1/3 (threshold : 10)
0 % Error 0/3 (threshold : 20)
Cyclomatic complexity
66.7 % Correct 2/3
33.3 % Warning 1/3 (threshold : 5)
0 % Error 0/3 (threshold : 10)
Methods of ts.service.ts
getKindAlias Complexity Index 6.7 Cyclomatic complexity 3
                            
                                
            
            
            
                /**
                 * Returns the SyntaxKind of an AST node or its alias if exists
                 * @param node
                 */
                static getKindAlias(node: Node): string { // ----------------------------- +0.4 Complexity index (+0.4 atomic)
                    let kind = node.getKindName(); // ------------------------------------ +1.4 Complexity index (+0.4 atomic, +1 structural)
                    for (const alias of KindAliases) { // -------------------------------- +1.3 Complexity index (+0.3 atomic, +1 structural)
                        if (alias.aliases.includes(kind)) { // --------------------------- +3.0 Complexity index (+0.5 atomic, +0.5 nesting, +2 structural)
                            kind = alias.name; // ---------------------------------------- +0.4 Complexity index (+0.4 atomic)
                            break;
                        }
                    }
                    return kind; // ------------------------------------------------------ +0.2 Complexity index (+0.2 atomic)
                }
            
                            
                        
getName Complexity Index 6.6 Cyclomatic complexity 2
                            
                                
                
            
            
                /**
                 * Gets the name of a Node
                 * @param node // The AST node
                 */
                static getName(node: Node): string { // --------------------------------------- +0.4 Complexity index (+0.4 atomic)
                    switch (node.getKind()) { // ---------------------------------------------- +2.3 Complexity index (+0.3 atomic, +2 structural)
                        case SyntaxKind.ClassDeclaration: // ---------------------------------- +0.3 Complexity index (+0.3 atomic)
                        case SyntaxKind.FunctionDeclaration: // ------------------------------- +0.3 Complexity index (+0.3 atomic)
                        case SyntaxKind.MethodDeclaration: // --------------------------------- +0.3 Complexity index (+0.3 atomic)
                        case SyntaxKind.Parameter: // ----------------------------------------- +0.3 Complexity index (+0.3 atomic)
                            return node.compilerNode['name']?.['escapedText'] ?? ''; // ------- +1.7 Complexity index (+0.7 atomic, +1 aggregation)
                        case SyntaxKind.Identifier: // ---------------------------------------- +0.3 Complexity index (+0.3 atomic)
                            return node.compilerNode['escapedText']; // ----------------------- +0.4 Complexity index (+0.4 atomic)
                        default: // ----------------------------------------------------------- +0.1 Complexity index (+0.1 atomic)
                            return undefined; // ---------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                    }
                }
            
                            
                        
isFunctionCall Complexity Index 19.6 Cyclomatic complexity 9
                            
                                
                
            
            
                /**
                 * Checks if a node is a call to a function or method
                 * Example : a.slice(1)
                 * @param node      // The node to check
                 */
                static isFunctionCall(node: Node): boolean { // ----------------------------------------------------------------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                    if (node.getKind() === SyntaxKind.PropertyAccessExpression) { // -------------------------------------------------------------------------------------- +2.6 Complexity index (+0.6 atomic, +2 structural)
                        return false; // ---------------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                    }
                    const parent: Node = node?.getParent(); // ------------------------------------------------------------------------------------------------------------ +1.5 Complexity index (+0.5 atomic, +1 structural)
                    if (!parent) { // ------------------------------------------------------------------------------------------------------------------------------------- +1.2 Complexity index (+0.2 atomic, +1 structural)
                        return false; // ---------------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                    }
                    const grandParent: Node = parent?.getParent(); // ----------------------------------------------------------------------------------------------------- +1.5 Complexity index (+0.5 atomic, +1 structural)
                    if (!grandParent) { // -------------------------------------------------------------------------------------------------------------------------------- +1.2 Complexity index (+0.2 atomic, +1 structural)
                        return false; // ---------------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                    }
                    const grandParentCall = grandParent.getKind() === SyntaxKind.CallExpression && grandParent.compilerNode['expression'].end === node.getEnd(); // ------- +4.6 Complexity index (+1.6 atomic, +3 structural)
                    const parentCall = parent.getKind() === SyntaxKind.CallExpression && parent.compilerNode['expression'].end === node.getEnd(); // ---------------------- +4.6 Complexity index (+1.6 atomic, +3 structural)
            
                    return parentCall || grandParentCall; // -------------------------------------------------------------------------------------------------------------- +1.5 Complexity index (+0.5 atomic, +1 structural)
                }