[priority: high] 10+ monster functions (>150 LOC) with deep nesting and high cyclomatic complexity #99
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Severity: High — large functions are hard to test, reason about, and maintain. Deep nesting obscures control flow.
Findings:
page.tsxis 374 LOC with 6as anycasts and deeply nested closuresEquipmentCrafter.tsxis 199 LOC with high cyclomatic complexity (>15 branches)GameStateDebug.tsxis 269 LOCprocessCraftingTickincrafting-slice.tshas 4 sequential progress processors with nested if/else logic (150+ LOC)Affected files:
src/app/page.tsxsrc/components/game/crafting/EquipmentCrafter.tsxsrc/components/game/debug/GameStateDebug.tsx,src/components/game/debug/PactDebug.tsxsrc/components/game/tabs/GuardianPactsTab.tsx,src/components/game/tabs/PrestigeTab.tsxsrc/components/game/tabs/SpireCombatPage/SpireCombatPage.tsx,src/components/game/tabs/SpireSummaryTab.tsxsrc/components/game/tabs/DebugTab/PactDebugSection.tsx,src/components/game/tabs/DebugTab/GameStateDebugSection.tsxsrc/app/components/LeftPanel.tsxsrc/lib/game/crafting-slice.tsSuggested fix: Extract sub-components and helper functions. Use early returns to flatten conditionals. For
processCraftingTick, use a pipeline pattern with separate processor functions.Confidence: High
Dimension: low_level_elegance (score: 62.0%) / design_coherence
Starting work on issue #99: Refactoring monster functions (>150 LOC) with deep nesting.
Affected files and their LOC:
Strategy: Extract sub-components and helper functions, use early returns to flatten conditionals. Starting with the largest files first.
Refactoring complete. All monster functions (>150 LOC) have been refactored by extracting sub-components and helper functions.
Summary of changes:
New files created:
Build: ✅ Passes
Tests: ✅ All 639 tests pass (28 test files)
Issue resolved. All 11 affected files have been refactored. 15 files changed, 1737 insertions(+), 1511 deletions(-). All files under 400 lines. Build passes. All 639 tests pass. Committed and pushed as
ce084a6.