complexity-guard 0.2.0 → 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.
Files changed (2) hide show
  1. package/README.md +31 -15
  2. package/package.json +6 -6
package/README.md CHANGED
@@ -22,29 +22,42 @@ complexity-guard src/
22
22
 
23
23
  ```
24
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
25
+ 42:0 ✓ ok Function 'validateCredentials' cyclomatic 3 cognitive 2
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]
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
31
33
 
32
- Top complexity hotspots:
34
+ Top cyclomatic hotspots:
33
35
  1. handleComplexAuthFlow (src/auth/login.ts:89) complexity 25
34
36
  2. processPayment (src/checkout/payment.ts:156) complexity 18
35
- 3. validateFormData (src/forms/validator.ts:34) complexity 15
37
+
38
+ Top cognitive hotspots:
39
+ 1. handleComplexAuthFlow (src/auth/login.ts:89) complexity 32
40
+ 2. processLoginFlow (src/auth/login.ts:67) complexity 18
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
36
45
 
37
46
  ✗ 4 problems (1 errors, 3 warnings)
38
47
  ```
39
48
 
40
49
  ## Features
41
50
 
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
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
55
+ - **Console + JSON Output**: Human-readable terminal display and machine-readable JSON for CI integration
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
58
+ - **Zero Config**: Works out of the box with sensible defaults, optional `.complexityguard.json` for customization
59
+ - **Single Binary**: No runtime dependencies, runs offline, fast startup
60
+ - **Error-Tolerant Parsing**: Tree-sitter based parser handles syntax errors gracefully, continues analysis on remaining files
48
61
 
49
62
  ## Configuration
50
63
 
@@ -57,10 +70,13 @@ Create a `.complexityguard.json` file in your project root to customize behavior
57
70
  "exclude": ["**/*.test.ts", "**/*.spec.ts", "node_modules/**"]
58
71
  },
59
72
  "thresholds": {
60
- "cyclomatic": {
61
- "warning": 10,
62
- "error": 20
63
- }
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 }
64
80
  },
65
81
  "counting_rules": {
66
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.2.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.2.0",
17
- "@complexity-guard/darwin-x64": "0.2.0",
18
- "@complexity-guard/linux-arm64": "0.2.0",
19
- "@complexity-guard/linux-x64": "0.2.0",
20
- "@complexity-guard/windows-x64": "0.2.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": {