Genese complexity report

<- code.service.ts
Methods : 3
Complexity index : 40.4
Cyclomatic complexity : 15
Cognitive complexity
33.3 % Correct 1/3
66.7 % Warning 2/3 (threshold : 10)
0 % Error 0/3 (threshold : 20)
Cyclomatic complexity
33.3 % Correct 1/3
66.7 % Warning 2/3 (threshold : 5)
0 % Error 0/3 (threshold : 10)
Methods of code.service.ts
getCode Complexity Index 12.7 Cyclomatic complexity 3
                            
                                
            
            
            
                /**
                 * Creates a Code object from the content of a given code (as string)
                 * @param text      // The content of the code
                 * @param start
                 */
                static getCode(text: string, start = 0): Code { // ----------------------------- +0.6 Complexity index (+0.6 atomic)
                    if (!text) { // ------------------------------------------------------------ +1.2 Complexity index (+0.2 atomic, +1 structural)
                        return undefined; // --------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                    }
                    const code: Code = new Code(); // ------------------------------------------ +0.5 Complexity index (+0.5 atomic)
                    code.start = start; // ----------------------------------------------------- +0.4 Complexity index (+0.4 atomic)
                    code.text = text; // ------------------------------------------------------- +0.4 Complexity index (+0.4 atomic)
                    const textLines: string[] = text.split('\n'); // --------------------------- +1.7 Complexity index (+0.7 atomic, +1 structural)
                    let issue = 1; // ---------------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
                    for (const textLine of textLines) { // ------------------------------------- +1.3 Complexity index (+0.3 atomic, +1 structural)
                        const line = new CodeLine(); // ---------------------------------------- +0.4 Complexity index (+0.4 atomic)
                        line.code = code; // --------------------------------------------------- +0.4 Complexity index (+0.4 atomic)
                        line.text = textLine; // ----------------------------------------------- +0.4 Complexity index (+0.4 atomic)
                        line.issue = issue; // ------------------------------------------------- +0.4 Complexity index (+0.4 atomic)
                        line.start = start; // ------------------------------------------------- +0.4 Complexity index (+0.4 atomic)
                        line.end = start + textLine.length + 1; // ----------------------------- +0.9 Complexity index (+0.9 atomic)
                        code.lines.push(line); // ---------------------------------------------- +1.4 Complexity index (+0.4 atomic, +1 structural)
                        issue++; // ------------------------------------------------------------ +0.1 Complexity index (+0.1 atomic)
                        start = line.end; // --------------------------------------------------- +0.4 Complexity index (+0.4 atomic)
                    }
                    code.lines[code.lines.length - 1].end = text.length; // -------------------- +1.1 Complexity index (+1.1 atomic)
                    return code; // ------------------------------------------------------------ +0.2 Complexity index (+0.2 atomic)
                }
            
                            
                        
getLineIssue Complexity Index 8.4 Cyclomatic complexity 6
                            
                                
                
            
            
                /**
                 * Returns the number of the CodeLine at a given pos in the code
                 * @param code      // The Code where to search
                 * @param position  // The pos where we search the number of its line
                 */
                static getLineIssue(code: Code, position: number): number { // ----------------------------------- +0.4 Complexity index (+0.4 atomic)
                    if (position < 0 || position > code?.end) { // ----------------------------------------------- +3.0 Complexity index (+1.0 atomic, +2 structural)
                        return 0; // ----------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                    }
                    return  code.lines.filter(l => l.start <= position && l.end > position)?.[0].issue; // ------- +4.8 Complexity index (+1.8 atomic, +3 structural)
                }
            
                            
                        
isEndingWithBlockComments Complexity Index 19.3 Cyclomatic complexity 6
                            
                                
                
            
            
            
                isEndingWithBlockComments(line: CodeLine): boolean { // --------------------------------------- +0.3 Complexity index (+0.3 atomic)
                    const text = line.textWithoutSlashComments; // -------------------------------------------- +0.4 Complexity index (+0.4 atomic)
                    if (line.previousLine?.isEndingWithBlockComments) { // ------------------------------------ +1.4 Complexity index (+0.4 atomic, +1 structural)
                        const splitEndBlockComments = text.split(/\*\//); // ---------------------------------- +2.9 Complexity index (+0.5 atomic, +0.4 aggregation, +2 structural)
                        if (splitEndBlockComments.length === 1) { // ------------------------------------------ +2.0 Complexity index (+0.5 atomic, +0.5 nesting, +1 structural)
                            return true; // ------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                        }
                        const lastElement = splitEndBlockComments[splitEndBlockComments.length - 1]; // ------- +0.7 Complexity index (+0.7 atomic)
                        return /\/\*/.test(lastElement) ?? false; // ------------------------------------------ +3.1 Complexity index (+0.6 atomic, +0.5 aggregation, +2 structural)
                    }
                    const splittedText = text?.split(/\/\*/); // ---------------------------------------------- +2.9 Complexity index (+0.5 atomic, +0.4 aggregation, +2 structural)
                    if (splittedText.length === 1) { // ------------------------------------------------------- +1.5 Complexity index (+0.5 atomic, +1 structural)
                        return false; // ---------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)
                    }
                    const lastCommentedBlock = splittedText[splittedText.length - 1]; // ---------------------- +0.7 Complexity index (+0.7 atomic)
                    return !/\*\//.test(lastCommentedBlock) ?? false; // -------------------------------------- +3.0 Complexity index (+0.6 atomic, +0.4 aggregation, +2 structural)
                }