Code Complexity Metrics Computed by AnyTool
AnyTool's Code Complexity Analyzer parses JavaScript, TypeScript, JSX and TSX with the real TypeScript compiler (ts.createSourceFile) rather than regex, so metrics reflect the actual syntax tree. Cyclomatic complexity counts every if, for, while, do, case, catch, ternary and logical operator (&&, ||, ??), while cognitive complexity adds nesting penalties per the SonarSource model. It also derives the full Halstead suite and a 0-100 maintainability index with an A-F grade.
- Uses the bundled TypeScript compiler AST, not keyword counting
- Reports cyclomatic, cognitive, Halstead and maintainability index
- Maintainability index uses 171 - 5.2*ln(HV) - 0.23*CC - 16.2*ln(SLOC), normalized to 0-100
- Metrics are computed per function and aggregated per file
