Commit 19c7baa
authored
refactor: decompose ast-analysis visitor framework (#771)
* fix: replace empty catch blocks with structured error handling
Replace catch blocks that silently swallow errors with proper error
variable capture and debug() logging across 10 files. This addresses
Pillar II (Rule 10: emptyCatch) violations identified by the gauntlet
audit. Files that already had proper error handling were verified and
left unchanged.
* refactor: add error-handling helpers for intentional catch suppression
* refactor: extract visitor dispatch helpers from walkWithVisitors
Decompose walkWithVisitors (cognitive=65, halstead.bugs=1.05) into focused
helper functions: mergeFunctionNodeTypes, initVisitors, isSkipped,
dispatchEnterFunction, dispatchEnterNode, dispatchExitNode, clearSkipFlags,
dispatchExitFunction, collectResults. The main function is now a thin
orchestrator delegating to single-purpose dispatch helpers.
* refactor: extract parameter and callee resolution helpers from visitor-utils
Split extractParamNames by extracting extractRestParamNames,
extractObjectDestructNames, and extractArrayDestructNames. Extract
resolveOptionalChainCallee from resolveCalleeName. Reduces cognitive
complexity and cyclomatic complexity of the two main functions.
* refactor: decompose handleVarDeclarator in dataflow-visitor
Extract resolveValueNode, unwrapExpressionList, recordDestructuredAssignment,
and recordSimpleAssignment from the monolithic handleVarDeclarator function.
Reduces cognitive complexity from 48 to focused single-purpose helpers.
* refactor: extract classifyNode helper and simplify complexity-visitor
Consolidate the enterNode classification logic into a single classifyNode
function. Simplify enterFunction/exitFunction by merging equivalent branches
for fileLevelWalk mode. Reduces cognitive complexity from 37 to focused
single-purpose helpers.
* refactor: decompose ast-store-visitor name extraction and node collection
Extract extractThrowName, extractAwaitName from extractName (removed).
Extract resolveNameAndText from collectNode to separate per-kind name/text
resolution from the row-building logic. Reduces cognitive complexity and
cyclomatic branching in the visitor factory.
* refactor: decompose engine.ts native analysis and deduplicate MI override
Extract detectNativeNeeds and runNativeFileAnalysis from runNativeAnalysis
to separate needs-detection from per-file dispatch. Extract shared
overrideCyclomaticFromCfg helper to eliminate duplicated MI recalculation
in storeNativeCfgResults and storeCfgResults.
* refactor: extract named constants and sumCounts helper in metrics
Replace magic numbers in the MI formula with named constants (MI_BASE,
MI_VOLUME_COEFF, etc.) and the Halstead bugs divisor. Extract sumCounts
helper from computeHalsteadDerived. Reduces halsteadEffort and addresses
Rule 7 magic-values warning.
* fix: address Greptile review comments in engine.ts (#771)
- Move NativeAnalysisNeeds interface before JSDoc block and fix stale
doc-comment that referenced a non-existent return value
- Add debug log when overrideCyclomaticFromCfg skips due to
cfgCyclomatic <= 0, making the WASM-path behavior change visible
- Remove duplicate hasFuncBody arrow in ensureWasmTreesIfNeeded,
reuse the module-level function instead
* fix: relocate orphaned JSDoc to runNativeAnalysis (#771)
* fix: remove duplicate function declarations from merge (#771)1 parent 1e31c97 commit 19c7baa
1 file changed
Lines changed: 11 additions & 24 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | 106 | | |
113 | 107 | | |
114 | 108 | | |
115 | 109 | | |
116 | 110 | | |
117 | 111 | | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
| |||
259 | 259 | | |
260 | 260 | | |
261 | 261 | | |
262 | | - | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
263 | 267 | | |
264 | 268 | | |
265 | 269 | | |
| |||
325 | 329 | | |
326 | 330 | | |
327 | 331 | | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | 332 | | |
346 | 333 | | |
347 | 334 | | |
| |||
0 commit comments