Commit 72edbe9
committed
refactor(dce): extract configuration into explicit value (Task 2)
Replace global config reads with explicit ~config parameter threading
throughout the DCE analysis pipeline. This makes the analysis pure
and testable with different configurations.
## Changes
### New module
- DceConfig: Encapsulates DCE configuration (cli + run config)
- DceConfig.current() captures global state once
- All analysis functions now take explicit ~config parameter
### DCE Analysis (fully pure - no global reads)
- DeadCode: threads config to all Dead* modules
- DeadValue: replaced ~15 !Cli.debug reads with config.cli.debug
- DeadType: replaced ~7 !Cli.debug reads with config.cli.debug
- DeadOptionalArgs: takes ~config, passes to Log_.warning
- DeadModules: uses config.run.transitive
- DeadCommon: threads config through reporting pipeline
- WriteDeadAnnotations: uses config.cli.write/json
- ProcessDeadAnnotations: uses config.cli.live_names/live_paths
### Logging infrastructure
- Log_.warning: now requires ~config (no optional)
- Log_.logIssue: now requires ~config (no optional)
- Log_.Stats.report: now requires ~config (no optional)
- Consistent API - no conditional logic on Some/None
### Non-DCE analyses (call DceConfig.current() at use sites)
- Exception: 4 call sites updated
- Arnold: 7 call sites updated
- TODO: Thread config through these for full purity
### Other
- Common.ml: removed unused lineAnnotationStr field
- Reanalyze: single DceConfig.current() call at entry point
- DEADCODE_REFACTOR_PLAN.md: updated Task 2, added verification task
## Impact
✅ DCE analysis is now pure - takes explicit config, no global reads
✅ All config parameters required (zero 'config option' types)
✅ Can run analysis with different configs without mutating globals
✅ All tests pass - no regressions
## Remaining Work (Task 2)
- Thread config through Exception/Arnold to eliminate DceConfig.current()
- Verify zero DceConfig.current() calls in analysis code
Signed-off-by: Cursor AI <ai@cursor.com>
Signed-off-by: Cristiano Calcagno <cristianoc@users.noreply.github.com>1 parent a4c5466 commit 72edbe9
File tree
16 files changed
+276
-195
lines changed- analysis
- reanalyze
- src
- src
16 files changed
+276
-195
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
47 | 49 | | |
48 | 50 | | |
49 | 51 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
152 | | - | |
153 | | - | |
154 | | - | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
155 | 159 | | |
156 | 160 | | |
157 | 161 | | |
158 | | - | |
| 162 | + | |
159 | 163 | | |
160 | 164 | | |
161 | 165 | | |
| |||
253 | 257 | | |
254 | 258 | | |
255 | 259 | | |
256 | | - | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
257 | 274 | | |
258 | 275 | | |
259 | 276 | | |
| |||
271 | 288 | | |
272 | 289 | | |
273 | 290 | | |
274 | | - | |
| 291 | + | |
275 | 292 | | |
276 | 293 | | |
277 | 294 | | |
| 295 | + | |
278 | 296 | | |
279 | 297 | | |
280 | | - | |
| 298 | + | |
| 299 | + | |
281 | 300 | | |
282 | 301 | | |
283 | 302 | | |
| |||
295 | 314 | | |
296 | 315 | | |
297 | 316 | | |
| 317 | + | |
298 | 318 | | |
299 | 319 | | |
300 | 320 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | | - | |
| 114 | + | |
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
128 | | - | |
| 128 | + | |
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| |||
610 | 610 | | |
611 | 611 | | |
612 | 612 | | |
613 | | - | |
| 613 | + | |
614 | 614 | | |
615 | 615 | | |
616 | 616 | | |
| |||
632 | 632 | | |
633 | 633 | | |
634 | 634 | | |
635 | | - | |
| 635 | + | |
| 636 | + | |
636 | 637 | | |
637 | 638 | | |
638 | 639 | | |
| |||
699 | 700 | | |
700 | 701 | | |
701 | 702 | | |
702 | | - | |
| 703 | + | |
| 704 | + | |
703 | 705 | | |
704 | 706 | | |
705 | 707 | | |
| |||
873 | 875 | | |
874 | 876 | | |
875 | 877 | | |
876 | | - | |
| 878 | + | |
877 | 879 | | |
878 | 880 | | |
879 | 881 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
| 14 | + | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
28 | | - | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | | - | |
| 32 | + | |
32 | 33 | | |
0 commit comments