ts-complexity-cli
v1.0.0
Published
Measure cyclomatic complexity of TypeScript/JavaScript files
Downloads
143
Maintainers
Readme
ts-complexity-cli
Measure cyclomatic complexity of TypeScript/JavaScript files.
Install
npm install -g ts-complexity-cliUsage
# Analyze files matching a glob pattern
ts-complexity "src/**/*.ts"
# Only show functions above a complexity threshold
ts-complexity "src/**/*.ts" --threshold 10
# Sort by complexity (descending)
ts-complexity "src/**/*.ts" --sort
# JSON output
ts-complexity "src/**/*.ts" --json
# Summary with averages and distribution
ts-complexity "src/**/*.ts" --summary
# Exclude patterns
ts-complexity "src/**/*.ts" --exclude "**/*.test.ts"
# Combine options
ts-complexity "src/**/*.ts" --threshold 5 --sort --summaryComplexity Levels
| Range | Level | Color | |-------|----------|--------| | 1-5 | Simple | Green | | 6-10 | Moderate | Yellow | | 11+ | Complex | Red |
Exit Codes
0— all functions are below the threshold (or no threshold set)1— at least one function exceeds the threshold
What It Counts
if, else if, for, while, do, switch case, &&, ||, ?:, catch
License
MIT
