Genese complexity report

<- cst-to-ast.ts
Methods : 3
Complexity index : 37.8
Cyclomatic complexity : 6
Cognitive complexity
33.3 % Correct 1/3
66.7 % Warning 2/3 (threshold : 10)
0 % Error 0/3 (threshold : 20)
Cyclomatic complexity
100 % Correct 3/3
0 % Warning 0/3 (threshold : 5)
0 % Error 0/3 (threshold : 10)
Methods of cst-to-ast.ts
cstToAst Complexity Index 11 Cyclomatic complexity 3
                            
                                
            
            
            
            /**
             * Convert a cst node to its corresponding ast node
             * @param cstNode
             * @param kind
             * @returns {any}
             */
            export function cstToAst(cstNode, kind = undefined): any { // ------------------------------------------------------------------- +0.5 Complexity index (+0.5 atomic)
            
                const children = cstNode.children; // --------------------------------------------------------------------------------------- +0.4 Complexity index (+0.4 atomic)
            
                try {
                    return require(`./cstToAstCases/${toKebabCase(cstNode.name || kind)}`).run(cstNode, children); // ----------------------- +5.1 Complexity index (+1.1 atomic, +4 structural)
                } catch (e) { // ------------------------------------------------------------------------------------------------------------ +1.2 Complexity index (+0.2 atomic, +1 structural)
                    const error = new Error(e.message + '!!!' + cstNode.location ? cstNode.location.startLine : cstNode.startLine) // ------- +3.2 Complexity index (+1.7 atomic, +0.5 nesting, +1 structural)
                    error.stack = e.stack; // ----------------------------------------------------------------------------------------------- +0.5 Complexity index (+0.5 atomic)
                    throw error; // --------------------------------------------------------------------------------------------------------- +0.1 Complexity index (+0.1 atomic)
                }
            }
            
                            
                        
toKebabCase Complexity Index 8.4 Cyclomatic complexity 2
                            
                                
            
            
            /**
             * Convert camelCase to kabab-case
             * @param text
             * @returns {string}
             */
            function toKebabCase(text: string): string { // ------------------------------------------ +0.4 Complexity index (+0.4 atomic)
                if (text === undefined) return ''; // ------------------------------------------------ +1.6 Complexity index (+0.6 atomic, +1 structural)
                return text.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase(); // ------- +6.4 Complexity index (+0.6 atomic, +2.8 aggregation, +3 structural)
            }
            
                            
                        
getBinaryOperatorName Complexity Index 18.4 Cyclomatic complexity 1
                            
                                
            
            
            /**
             * The the SyntaxKind corresponding to the given operator
             * @param operator
             * @returns {SyntaxKind.EqualsToken | SyntaxKind.GreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.EqualsEqualsToken | string | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.AsteriskToken | SyntaxKind.LessThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken | SyntaxKind.MinusToken}
             */
            export function getBinaryOperatorName(operator: string): string { // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.4 Complexity index (+0.4 atomic)
                switch (operator) { // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +1.2 Complexity index (+0.2 atomic, +1 structural)
                    case '>': // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                        return SyntaxKind.GreaterThanToken; // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                    case '>=': // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                        return SyntaxKind.GreaterThanEqualsToken; // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                    case '<': // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                        return SyntaxKind.LessThanToken; // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                    case '<=': // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                        return SyntaxKind.LessThanEqualsToken; // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                    case '+': // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                        return SyntaxKind.PlusToken; // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                    case '-': // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                        return SyntaxKind.MinusToken; // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                    case '*': // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                        return SyntaxKind.AsteriskToken; // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                    case '==': // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                        return SyntaxKind.EqualsEqualsToken; // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                    case '=': // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                        return SyntaxKind.EqualsToken; // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                    case '&&': // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                        return SyntaxKind.AmpersandAmpersandToken // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                    case '||': // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                        return SyntaxKind.BarBarToken // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                    case '!=': // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                        return SyntaxKind.ExclamationEqualsToken // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                    case '+=': // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                        return SyntaxKind.PlusEqualsToken // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +0.3 Complexity index (+0.3 atomic)
                    case '-=': // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                        return SyntaxKind.MinusEqualsToken // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                    case '*=': // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                        return SyntaxKind.AsteriskEqualsToken // -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                    case '/=': // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                        return SyntaxKind.SlashEqualsToken // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                    case '%=': // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                        return SyntaxKind.PercentEqualsToken // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                    case '&=': // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                        return SyntaxKind.AmpersandEqualsToken // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                    case '^=': // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                        return SyntaxKind.CaretEqualsToken // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                    case '|=': // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                        return SyntaxKind.BarEqualsToken // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                    case '<<=': // -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                        return SyntaxKind.LessThanLessThanEqualsToken // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +0.3 Complexity index (+0.3 atomic)
                    case '>>=': // -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                        return SyntaxKind.GreaterThanGreaterThanEqualsToken // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +0.3 Complexity index (+0.3 atomic)
                    case '>>>=': // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                        return SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                    case '?': // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                        return SyntaxKind.QuestionToken // -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                    case ':': // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                        return SyntaxKind.ColonToken // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                    case '|': // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                        return SyntaxKind.BarToken // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                    case '^': // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                        return SyntaxKind.CaretToken // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                    case '&': // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                        return SyntaxKind.AmpersandToken // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                    case '<<': // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                        return SyntaxKind.LessThanLessThanToken // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +0.3 Complexity index (+0.3 atomic)
                    case '>>': // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                        return SyntaxKind.GreaterThanGreaterThanToken // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +0.3 Complexity index (+0.3 atomic)
                    case '>>>': // -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                        return SyntaxKind.GreaterThanGreaterThanGreaterThanToken // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                    case '/': // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                        return SyntaxKind.SlashToken // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                    case '%': // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                        return SyntaxKind.PercentToken // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                    default: // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.1 Complexity index (+0.1 atomic)
                        return operator; // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                }
            }