complexity-guard 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +81 -0
- package/package.json +6 -6
package/README.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# ComplexityGuard
|
|
2
|
+
|
|
3
|
+
Fast complexity analysis for TypeScript/JavaScript — single static binary, zero dependencies.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
# Global install (CLI access from anywhere)
|
|
9
|
+
npm install -g complexity-guard
|
|
10
|
+
|
|
11
|
+
# Local/CI install (project dependency)
|
|
12
|
+
npm install --save-dev complexity-guard
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
complexity-guard src/
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Example Output
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
src/auth/login.ts
|
|
25
|
+
42:0 ✓ ok Function 'validateCredentials' has complexity 3 (threshold: 10) cyclomatic
|
|
26
|
+
67:0 ⚠ warning Function 'processLoginFlow' has complexity 12 (threshold: 10) cyclomatic
|
|
27
|
+
89:2 ✗ error Function 'handleComplexAuthFlow' has complexity 25 (threshold: 20) cyclomatic
|
|
28
|
+
|
|
29
|
+
Analyzed 12 files, 47 functions
|
|
30
|
+
Found 3 warnings, 1 errors
|
|
31
|
+
|
|
32
|
+
Top complexity hotspots:
|
|
33
|
+
1. handleComplexAuthFlow (src/auth/login.ts:89) complexity 25
|
|
34
|
+
2. processPayment (src/checkout/payment.ts:156) complexity 18
|
|
35
|
+
3. validateFormData (src/forms/validator.ts:34) complexity 15
|
|
36
|
+
|
|
37
|
+
✗ 4 problems (1 errors, 3 warnings)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Features
|
|
41
|
+
|
|
42
|
+
- **Cyclomatic Complexity** — McCabe metric with ESLint-aligned counting rules for accurate complexity measurement
|
|
43
|
+
- **Console + JSON Output** — Human-readable terminal display and machine-readable JSON for CI integration
|
|
44
|
+
- **Configurable Thresholds** — Warning (10) and error (20) levels, customizable per project via config file
|
|
45
|
+
- **Zero Config** — Works out of the box with sensible defaults, optional `.complexityguard.json` for customization
|
|
46
|
+
- **Single Binary** — No runtime dependencies, runs offline, fast startup
|
|
47
|
+
- **Error-Tolerant Parsing** — Tree-sitter based parser handles syntax errors gracefully, continues analysis on remaining files
|
|
48
|
+
|
|
49
|
+
## Configuration
|
|
50
|
+
|
|
51
|
+
Create a `.complexityguard.json` file in your project root to customize behavior:
|
|
52
|
+
|
|
53
|
+
```json
|
|
54
|
+
{
|
|
55
|
+
"files": {
|
|
56
|
+
"include": ["src/**/*.ts", "src/**/*.tsx"],
|
|
57
|
+
"exclude": ["**/*.test.ts", "**/*.spec.ts", "node_modules/**"]
|
|
58
|
+
},
|
|
59
|
+
"thresholds": {
|
|
60
|
+
"cyclomatic": {
|
|
61
|
+
"warning": 10,
|
|
62
|
+
"error": 20
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"counting_rules": {
|
|
66
|
+
"logical_operators": true,
|
|
67
|
+
"nullish_coalescing": true,
|
|
68
|
+
"optional_chaining": true,
|
|
69
|
+
"switch_case_mode": "perCase"
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Links
|
|
75
|
+
|
|
76
|
+
- [GitHub](https://github.com/benvds/complexity-guard)
|
|
77
|
+
- [Documentation](https://github.com/benvds/complexity-guard#documentation)
|
|
78
|
+
|
|
79
|
+
## License
|
|
80
|
+
|
|
81
|
+
MIT
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"name": "Ben van de Sande",
|
|
5
5
|
"email": "info@getlean.digital"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.1.
|
|
7
|
+
"version": "0.1.9",
|
|
8
8
|
"description": "Fast complexity analysis for TypeScript/JavaScript — single static binary",
|
|
9
9
|
"bin": {
|
|
10
10
|
"complexity-guard": "bin/complexity-guard.js"
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
"bin/"
|
|
14
14
|
],
|
|
15
15
|
"optionalDependencies": {
|
|
16
|
-
"@complexity-guard/darwin-arm64": "0.1.
|
|
17
|
-
"@complexity-guard/darwin-x64": "0.1.
|
|
18
|
-
"@complexity-guard/linux-arm64": "0.1.
|
|
19
|
-
"@complexity-guard/linux-x64": "0.1.
|
|
20
|
-
"@complexity-guard/windows-x64": "0.1.
|
|
16
|
+
"@complexity-guard/darwin-arm64": "0.1.9",
|
|
17
|
+
"@complexity-guard/darwin-x64": "0.1.9",
|
|
18
|
+
"@complexity-guard/linux-arm64": "0.1.9",
|
|
19
|
+
"@complexity-guard/linux-x64": "0.1.9",
|
|
20
|
+
"@complexity-guard/windows-x64": "0.1.9"
|
|
21
21
|
},
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"repository": {
|