Complexity refactor plan #35
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
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?
Complexity Refactor Proposals
Use these only if we deliberately want to reduce frontend control-flow complexity before enabling the ESLint
complexityrule. Work each step independently and stop to commit after each completed step.Why this section exists
complexityat12currently reports these hotspots:src/App.tsxreadHashMapViewAppsrc/api/ws.tsws.onmessagesrc/maps/leafletMap.tsLeafletMapAdapter.rendersrc/pages/NodesPage.tsxdetailSectionsdetailSectionsandreadHashMapView.Step 1: Extract
Appbootstrap orchestrationAppsrc/App.tsxPromise.allSettled(...)bootstrap flow into a dedicated helper or hook.Appresponsible for wiring state setters and rendering only.cd web && npm run typecheckcd web && npm run lintcd web && npm run testStep 2: Split log loading flow from
Appsrc/App.tsxuseLogLoader-style hook.Appcomplexity further without changing page-level behavior.cd web && npm run typecheckcd web && npm run lintcd web && npm run testStep 3: Replace WebSocket message branching with typed dispatch
ws.onmessageinto explicit event handlerssrc/api/ws.tscd web && npm run typecheckcd web && npm run lintcd web && npm run testStep 4: Decompose Leaflet marker/circle reconciliation
LeafletMapAdapter.renderinto smaller reconciliation helperssrc/maps/leafletMap.tscd web && npm run typecheckcd web && npm run lintcd web && npm run testcd web && npm run buildStep 5: Convert node detail section assembly to data-driven helpers
detailSectionsinto per-section builderssrc/pages/NodesPage.tsxcd web && npm run typecheckcd web && npm run lintcd web && npm run testStep 6: Normalize URL hash parsing helpers only if already touching map-view code
readHashMapViewsrc/App.tsxcd web && npm run typecheckcd web && npm run lintEnabling Guidance After Refactors
Re-trial
complexityafter Steps 1-4complexityat15first, then12.warnfirst if the remaining reports are low-count and high-signal.erroronly if the remaining failures are rare and clearly actionable.Step 6: Trial useful but more opinionated consistency rules
@typescript-eslint/consistent-indexed-object-styleRecord<K, V>and index signatures.Step 7: Trial potentially good but higher-churn policy rules
Step 7: Trial potentially good but higher-churn policy rules
import-x/no-default-exportcomplexityormax-lines-per-functioneslint-plugin-unicornrules if we decide to add that pluginimport-x/no-default-exportis only sensible if we want to move away from default-exported pages/components.eslint-plugin-unicornwould be a separate plugin-adoption decision.import-x/no-default-export.web/srchas no default exports, so this adds policy without code churn.vite.config.ts, where the default export is part of the host tool's expected shape.complexityyet.12reports4errors in central files:src/App.tsxsrc/api/ws.tssrc/pages/NodesPage.tsxmax-lines-per-functionyet.80reports4errors, including:src/App.tsxsrc/pages/MapPage.tsxsrc/App.test.tsxeslint-plugin-unicornin this step.web/package.json, so that would be a separate dependency/policy change.