complexity-guard 0.2.1 → 0.3.0
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 +19 -11
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -24,7 +24,9 @@ complexity-guard src/
|
|
|
24
24
|
src/auth/login.ts
|
|
25
25
|
42:0 ✓ ok Function 'validateCredentials' cyclomatic 3 cognitive 2
|
|
26
26
|
67:0 ⚠ warning Function 'processLoginFlow' cyclomatic 12 cognitive 18
|
|
27
|
+
[halstead vol 843 diff 14.1 effort 11886] [length 34 params 3 depth 4]
|
|
27
28
|
89:2 ✗ error Method 'handleComplexAuthFlow' cyclomatic 25 cognitive 32
|
|
29
|
+
[halstead vol 1244 diff 18.6 effort 23135 bugs 0.41] [length 62 params 4 depth 6]
|
|
28
30
|
|
|
29
31
|
Analyzed 12 files, 47 functions
|
|
30
32
|
Found 3 warnings, 1 errors
|
|
@@ -37,15 +39,22 @@ Top cognitive hotspots:
|
|
|
37
39
|
1. handleComplexAuthFlow (src/auth/login.ts:89) complexity 32
|
|
38
40
|
2. processLoginFlow (src/auth/login.ts:67) complexity 18
|
|
39
41
|
|
|
42
|
+
Top Halstead volume hotspots:
|
|
43
|
+
1. handleComplexAuthFlow (src/auth/login.ts:89) volume 1244
|
|
44
|
+
2. processLoginFlow (src/auth/login.ts:67) volume 843
|
|
45
|
+
|
|
40
46
|
✗ 4 problems (1 errors, 3 warnings)
|
|
41
47
|
```
|
|
42
48
|
|
|
43
49
|
## Features
|
|
44
50
|
|
|
45
|
-
- **
|
|
46
|
-
- **
|
|
51
|
+
- **Cyclomatic Complexity**: McCabe metric counting independent code paths — measures testability
|
|
52
|
+
- **Cognitive Complexity**: SonarSource-based metric with nesting depth penalties — measures understandability
|
|
53
|
+
- **Halstead Metrics**: Information-theoretic vocabulary density, volume, difficulty, effort, and estimated bugs
|
|
54
|
+
- **Structural Metrics**: Function length, parameter count, nesting depth, file length, and export count
|
|
47
55
|
- **Console + JSON Output**: Human-readable terminal display and machine-readable JSON for CI integration
|
|
48
|
-
- **Configurable Thresholds**: Warning and error levels for
|
|
56
|
+
- **Configurable Thresholds**: Warning and error levels for all four metric families, customizable per project
|
|
57
|
+
- **Selective Metrics**: Use `--metrics cyclomatic,halstead` to compute only specific families
|
|
49
58
|
- **Zero Config**: Works out of the box with sensible defaults, optional `.complexityguard.json` for customization
|
|
50
59
|
- **Single Binary**: No runtime dependencies, runs offline, fast startup
|
|
51
60
|
- **Error-Tolerant Parsing**: Tree-sitter based parser handles syntax errors gracefully, continues analysis on remaining files
|
|
@@ -61,14 +70,13 @@ Create a `.complexityguard.json` file in your project root to customize behavior
|
|
|
61
70
|
"exclude": ["**/*.test.ts", "**/*.spec.ts", "node_modules/**"]
|
|
62
71
|
},
|
|
63
72
|
"thresholds": {
|
|
64
|
-
"cyclomatic": {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
},
|
|
68
|
-
"
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
73
|
+
"cyclomatic": { "warning": 10, "error": 20 },
|
|
74
|
+
"cognitive": { "warning": 15, "error": 25 },
|
|
75
|
+
"halstead_volume": { "warning": 500, "error": 1000 },
|
|
76
|
+
"halstead_effort": { "warning": 5000, "error": 10000 },
|
|
77
|
+
"function_length": { "warning": 25, "error": 50 },
|
|
78
|
+
"params": { "warning": 3, "error": 6 },
|
|
79
|
+
"nesting": { "warning": 3, "error": 5 }
|
|
72
80
|
},
|
|
73
81
|
"counting_rules": {
|
|
74
82
|
"logical_operators": true,
|
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.
|
|
7
|
+
"version": "0.3.0",
|
|
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.
|
|
17
|
-
"@complexity-guard/darwin-x64": "0.
|
|
18
|
-
"@complexity-guard/linux-arm64": "0.
|
|
19
|
-
"@complexity-guard/linux-x64": "0.
|
|
20
|
-
"@complexity-guard/windows-x64": "0.
|
|
16
|
+
"@complexity-guard/darwin-arm64": "0.3.0",
|
|
17
|
+
"@complexity-guard/darwin-x64": "0.3.0",
|
|
18
|
+
"@complexity-guard/linux-arm64": "0.3.0",
|
|
19
|
+
"@complexity-guard/linux-x64": "0.3.0",
|
|
20
|
+
"@complexity-guard/windows-x64": "0.3.0"
|
|
21
21
|
},
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"repository": {
|