Genese complexity report

<- code-block-writer.d.ts
Methods : 49
Complexity index : 12.9
Cyclomatic complexity : 48
Cognitive complexity
100 % Correct 49/49
0 % Warning 0/49 (threshold : 10)
0 % Error 0/49 (threshold : 20)
Cyclomatic complexity
100 % Correct 49/49
0 % Warning 0/49 (threshold : 5)
0 % Error 0/49 (threshold : 10)
Methods of code-block-writer.d.ts
Complexity Index 0.3 Cyclomatic complexity 0
                            
                                
            
                /**
                 * Constructor.
                 * @param opts - Options for the writer.
                 */
                constructor(opts?: Partial<Options>); // ----------- +0.3 Complexity index (+0.3 atomic)
            
                            
                        
getOptions Complexity Index 0.2 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Gets the options.
                 */
                getOptions(): Options; // ----------------------- +0.2 Complexity index (+0.2 atomic)
            
                            
                        
queueIndentationLevel Complexity Index 0.2 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Queues the indentation level for the next lines written.
                 * @param indentationLevel - Indentation level to queue.
                 */
                queueIndentationLevel(indentationLevel: number): this; // ------------- +0.2 Complexity index (+0.2 atomic)
            
                            
                        
queueIndentationLevel Complexity Index 0.3 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Queues the indentation level for the next lines written using the provided indentation text.
                 * @param whitespaceText - Gets the indentation level from the indentation text.
                 */
                queueIndentationLevel(whitespaceText: string): this; // --------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
            
                            
                        
hangingIndent Complexity Index 0.3 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Writes the text within the provided action with hanging indentation.
                 * @param action - Action to perform with hanging indentation.
                 */
                hangingIndent(action: () => void): this; // --------------------------------------- +0.3 Complexity index (+0.3 atomic)
            
                            
                        
hangingIndentUnlessBlock Complexity Index 0.3 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Writes the text within the provided action with hanging indentation unless writing a block.
                 * @param action - Action to perform with hanging indentation unless a block is written.
                 */
                hangingIndentUnlessBlock(action: () => void): this; // --------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
            
                            
                        
setIndentationLevel Complexity Index 0.2 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Sets the current indentation level.
                 * @param indentationLevel - Indentation level to be at.
                 */
                setIndentationLevel(indentationLevel: number): this; // ------------ +0.2 Complexity index (+0.2 atomic)
            
                            
                        
setIndentationLevel Complexity Index 0.3 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Sets the current indentation using the provided indentation text.
                 * @param whitespaceText - Gets the indentation level from the indentation text.
                 */
                setIndentationLevel(whitespaceText: string): this; // -------------------------------------- +0.3 Complexity index (+0.3 atomic)
            
                            
                        
withIndentationLevel Complexity Index 0.4 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Sets the indentation level within the provided action and restores the writer's indentation
                 * state afterwards.
                 * @remarks Restores the writer's state after the action.
                 * @param indentationLevel - Indentation level to set.
                 * @param action - Action to perform with the indentation.
                 */
                withIndentationLevel(indentationLevel: number, action: () => void): this; // ----------------------------- +0.4 Complexity index (+0.4 atomic)
            
                            
                        
withIndentationLevel Complexity Index 0.5 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Sets the indentation level with the provided indentation text within the provided action
                 * and restores the writer's indentation state afterwards.
                 * @param whitespaceText - Gets the indentation level from the indentation text.
                 * @param action - Action to perform with the indentation.
                 */
                withIndentationLevel(whitespaceText: string, action: () => void): this; // ---------------------------- +0.5 Complexity index (+0.5 atomic)
            
                            
                        
getIndentationLevel Complexity Index 0.1 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Gets the current indentation level.
                 */
                getIndentationLevel(): number; // ------------------------------------------------- +0.1 Complexity index (+0.1 atomic)
            
                            
                        
block Complexity Index 0.3 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Writes a block using braces.
                 * @param block - Write using the writer within this block.
                 */
                block(block?: () => void): this; // ----------------------------------- +0.3 Complexity index (+0.3 atomic)
            
                            
                        
inlineBlock Complexity Index 0.3 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Writes an inline block with braces.
                 * @param block - Write using the writer within this block.
                 */
                inlineBlock(block?: () => void): this; // ----------------------------- +0.3 Complexity index (+0.3 atomic)
            
                            
                        
indent Complexity Index 0.2 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Indents the code one level for the current line.
                 */
                indent(times?: number): this; // ------------------------------ +0.2 Complexity index (+0.2 atomic)
            
                            
                        
indent Complexity Index 0.3 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Indents a block of code.
                 * @param block - Block to indent.
                 */
                indent(block: () => void): this; // ---------- +0.3 Complexity index (+0.3 atomic)
            
                            
                        
conditionalWriteLine Complexity Index 0.5 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Conditionally writes a line of text.
                 * @param condition - Condition to evaluate.
                 * @param textFunc - A function that returns a string to write if the condition is true.
                 */
                conditionalWriteLine(condition: boolean | undefined, textFunc: () => string): this; // ------------- +0.5 Complexity index (+0.5 atomic)
            
                            
                        
conditionalWriteLine Complexity Index 0.5 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Conditionally writes a line of text.
                 * @param condition - Condition to evaluate.
                 * @param text - Text to write if the condition is true.
                 */
                conditionalWriteLine(condition: boolean | undefined, text: string): this; // ------------------ +0.5 Complexity index (+0.5 atomic)
            
                            
                        
writeLine Complexity Index 0.3 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Writes a line of text.
                 * @param text - String to write.
                 */
                writeLine(text: string): this; // --------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
            
                            
                        
newLineIfLastNot Complexity Index 0.1 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Writes a newline if the last line was not a newline.
                 */
                newLineIfLastNot(): this; // -------------------------------------- +0.1 Complexity index (+0.1 atomic)
            
                            
                        
blankLineIfLastNot Complexity Index 0.1 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Writes a blank line if the last written text was not a blank line.
                 */
                blankLineIfLastNot(): this; // -------------------------------------------------- +0.1 Complexity index (+0.1 atomic)
            
                            
                        
conditionalBlankLine Complexity Index 0.3 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Writes a blank line if the condition is true.
                 * @param condition - Condition to evaluate.
                 */
                conditionalBlankLine(condition: boolean | undefined): this; // -------- +0.3 Complexity index (+0.3 atomic)
            
                            
                        
blankLine Complexity Index 0.1 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Writes a blank line.
                 */
                blankLine(): this; // ------------------------------------------------- +0.1 Complexity index (+0.1 atomic)
            
                            
                        
conditionalNewLine Complexity Index 0.3 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Writes a newline if the condition is true.
                 * @param condition - Condition to evaluate.
                 */
                conditionalNewLine(condition: boolean | undefined): this; // -------- +0.3 Complexity index (+0.3 atomic)
            
                            
                        
newLine Complexity Index 0.1 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Writes a newline.
                 */
                newLine(): this; // ------------------------------------------------- +0.1 Complexity index (+0.1 atomic)
            
                            
                        
quote Complexity Index 0.1 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Writes a quote character.
                 */
                quote(): this; // ---------------------- +0.1 Complexity index (+0.1 atomic)
            
                            
                        
quote Complexity Index 0.3 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Writes text surrounded in quotes.
                 * @param text - Text to write.
                 */
                quote(text: string): this; // ------------------ +0.3 Complexity index (+0.3 atomic)
            
                            
                        
spaceIfLastNot Complexity Index 0.1 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Writes a space if the last character was not a space.
                 */
                spaceIfLastNot(): this; // ----------------------------------------- +0.1 Complexity index (+0.1 atomic)
            
                            
                        
space Complexity Index 0.2 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Writes a space.
                 * @param times - Number of times to write a space.
                 */
                space(times?: number): this; // ------------------------------- +0.2 Complexity index (+0.2 atomic)
            
                            
                        
tabIfLastNot Complexity Index 0.1 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Writes a tab if the last character was not a tab.
                 */
                tabIfLastNot(): this; // --------------------------------------- +0.1 Complexity index (+0.1 atomic)
            
                            
                        
tab Complexity Index 0.2 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Writes a tab.
                 * @param times - Number of times to write a tab.
                 */
                tab(times?: number): this; // ------------------------------- +0.2 Complexity index (+0.2 atomic)
            
                            
                        
conditionalWrite Complexity Index 0.5 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Conditionally writes text.
                 * @param condition - Condition to evaluate.
                 * @param textFunc - A function that returns a string to write if the condition is true.
                 */
                conditionalWrite(condition: boolean | undefined, textFunc: () => string): this; // ----------------- +0.5 Complexity index (+0.5 atomic)
            
                            
                        
conditionalWrite Complexity Index 0.5 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Conditionally writes text.
                 * @param condition - Condition to evaluate.
                 * @param text - Text to write if the condition is true.
                 */
                conditionalWrite(condition: boolean | undefined, text: string): this; // ------------------ +0.5 Complexity index (+0.5 atomic)
            
                            
                        
write Complexity Index 0.3 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Writes the provided text.
                 * @param text - Text to write.
                 */
                write(text: string): this; // --------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
            
                            
                        
closeComment Complexity Index 0.1 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Writes text to exit a comment if in a comment.
                 */
                closeComment(): this; // ------------------------------------ +0.1 Complexity index (+0.1 atomic)
            
                            
                        
unsafeInsert Complexity Index 0.4 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Inserts text at the provided position.
                 *
                 * This method is "unsafe" because it won't update the state of the writer unless
                 * inserting at the end position. It is biased towards being fast at inserting closer
                 * to the start or end, but slower to insert in the middle. Only use this if
                 * absolutely necessary.
                 * @param pos - Position to insert at.
                 * @param text - Text to insert.
                 */
                unsafeInsert(pos: number, text: string): this; // ----------------------------------------------- +0.4 Complexity index (+0.4 atomic)
            
                            
                        
getLength Complexity Index 0.1 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Gets the length of the string in the writer.
                 */
                getLength(): number; // ----------------------------------- +0.1 Complexity index (+0.1 atomic)
            
                            
                        
isInComment Complexity Index 0.1 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Gets if the writer is currently in a comment.
                 */
                isInComment(): boolean; // --------------------------------- +0.1 Complexity index (+0.1 atomic)
            
                            
                        
isAtStartOfFirstLineOfBlock Complexity Index 0.1 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Gets if the writer is currently at the start of the first line of the text, block, or indentation block.
                 */
                isAtStartOfFirstLineOfBlock(): boolean; // ---------------------------------------------------------------------------- +0.1 Complexity index (+0.1 atomic)
            
                            
                        
isOnFirstLineOfBlock Complexity Index 0.1 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Gets if the writer is currently on the first line of the text, block, or indentation block.
                 */
                isOnFirstLineOfBlock(): boolean; // ---------------------------------------------------------------------- +0.1 Complexity index (+0.1 atomic)
            
                            
                        
isInString Complexity Index 0.1 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Gets if the writer is currently in a string.
                 */
                isInString(): boolean; // --------------------------------- +0.1 Complexity index (+0.1 atomic)
            
                            
                        
isLastNewLine Complexity Index 0.1 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Gets if the last chars written were for a newline.
                 */
                isLastNewLine(): boolean; // ------------------------------------ +0.1 Complexity index (+0.1 atomic)
            
                            
                        
isLastBlankLine Complexity Index 0.1 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Gets if the last chars written were for a blank line.
                 */
                isLastBlankLine(): boolean; // ------------------------------------- +0.1 Complexity index (+0.1 atomic)
            
                            
                        
isLastSpace Complexity Index 0.1 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Gets if the last char written was a space.
                 */
                isLastSpace(): boolean; // ------------------------------ +0.1 Complexity index (+0.1 atomic)
            
                            
                        
isLastTab Complexity Index 0.1 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Gets if the last char written was a tab.
                 */
                isLastTab(): boolean; // ------------------------------ +0.1 Complexity index (+0.1 atomic)
            
                            
                        
getLastChar Complexity Index 0.3 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Gets the last char written.
                 */
                getLastChar(): string | undefined; // -------- +0.3 Complexity index (+0.3 atomic)
            
                            
                        
endsWith Complexity Index 0.3 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Gets if the writer ends with the provided text.
                 * @param text - Text to check if the writer ends with the provided text.
                 */
                endsWith(text: string): boolean; // ------------------------------------------------- +0.3 Complexity index (+0.3 atomic)
            
                            
                        
iterateLastChars Complexity Index 1 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Iterates over the writer characters in reverse order. The iteration stops when a non-null or
                 * undefined value is returned from the action. The returned value is then returned by the method.
                 *
                 * @remarks It is much more efficient to use this method rather than `#toString()` since `#toString()`
                 * will combine the internal array into a string.
                 */
                iterateLastChars<T>(action: (char: string, index: number) => T | undefined): T | undefined; // ------------------- +1.0 Complexity index (+1.0 atomic)
            
                            
                        
iterateLastCharCodes Complexity Index 0.9 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Iterates over the writer character char codes in reverse order. The iteration stops when a non-null or
                 * undefined value is returned from the action. The returned value is then returned by the method.
                 *
                 * @remarks It is much more efficient to use this method rather than `#toString()` since `#toString()`
                 * will combine the internal array into a string. Additionally, this is slightly more efficient that
                 * `iterateLastChars` as this won't allocate a string per character.
                 */
                iterateLastCharCodes<T>(action: (charCode: number, index: number) => T | undefined): T | undefined; // -------------- +0.9 Complexity index (+0.9 atomic)
            
                            
                        
toString Complexity Index 0.2 Cyclomatic complexity 1
                            
                                
                
                /**
                 * Gets the writer's text.
                 */
                toString(): string; // ---------------------------------------------------------------------------------------- +0.2 Complexity index (+0.2 atomic)