Skip to content

Commit ebcbb08

Browse files
committed
fix: init cyclo complexity to 1
1 parent 9a27c2f commit ebcbb08

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/code-quality/complexity/CyclomaticComplexity.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import { CodeTokens } from '../tokenizer/CodeTokens';
66
export class CyclomaticComplexity {
77
/**
88
* The cyclomatic complexity of a function is calculated according to the following rules:
9-
* -1 is the base complexity of a function
9+
* 1 is the base complexity of a function
1010
* +1 for each 'if', 'for', 'case', '&&' or '||'
1111
* @param tokenizedCode
1212
* @return cyclomaticComplexity
1313
*/
1414
public compute(tokenizedCode: CodeTokens[]): number {
15-
let cyclomaticComplexity = -1;
15+
let cyclomaticComplexity = 1;
1616

1717
tokenizedCode.forEach((token) => {
1818
// console.log(`token: ${token}`);

0 commit comments

Comments
 (0)