mirror of
https://github.com/thedotmack/claude-mem
synced 2026-04-25 17:15:04 +02:00
Systematic cleanup of every error handling anti-pattern detected by the automated scanner. 289 issues fixed via code changes, 12 approved with specific technical justifications. Changes across 90 files: - GENERIC_CATCH (141): Added instanceof Error type discrimination - LARGE_TRY_BLOCK (82): Extracted helper methods to narrow try scope to ≤10 lines - NO_LOGGING_IN_CATCH (65): Added logger/console calls for error visibility - CATCH_AND_CONTINUE_CRITICAL_PATH (10): Added throw/return or approved overrides - ERROR_STRING_MATCHING (2): Approved with rationale (no typed error classes) - ERROR_MESSAGE_GUESSING (1): Replaced chained .includes() with documented pattern array - PROMISE_CATCH_NO_LOGGING (1): Added logging to .catch() handler Also fixes a detector bug where nested try/catch inside a catch block corrupted brace-depth tracking, causing false positives. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
13 KiB
13 KiB
Anti-Pattern Fix Checklist
Total: 301 issues | Fixed: 289 | Approved Overrides: 12 | Remaining: 0 Detector passes clean: 0 issues to fix
Every item gets fixed (logging added, try block narrowed, catch made specific, or error propagated) OR approved with a specific technical reason.
src/services/worker-service.ts (14 issues)
- :291 GENERIC_CATCH
- :291 CATCH_AND_CONTINUE_CRITICAL_PATH
- :375 LARGE_TRY_BLOCK
- :388 GENERIC_CATCH
- :388 CATCH_AND_CONTINUE_CRITICAL_PATH
- :489 CATCH_AND_CONTINUE_CRITICAL_PATH
- :536 CATCH_AND_CONTINUE_CRITICAL_PATH
- :574 LARGE_TRY_BLOCK
- :592 GENERIC_CATCH
- :592 CATCH_AND_CONTINUE_CRITICAL_PATH
- :696 ERROR_MESSAGE_GUESSING
- :837 CATCH_AND_CONTINUE_CRITICAL_PATH
- :849 CATCH_AND_CONTINUE_CRITICAL_PATH
- :912 LARGE_TRY_BLOCK
- :941 GENERIC_CATCH
- :941 CATCH_AND_CONTINUE_CRITICAL_PATH
- :961 LARGE_TRY_BLOCK
- :979 GENERIC_CATCH
- :979 CATCH_AND_CONTINUE_CRITICAL_PATH
src/services/sqlite/SessionStore.ts (7 issues)
- :449 LARGE_TRY_BLOCK
- :477 GENERIC_CATCH
- :477 CATCH_AND_CONTINUE_CRITICAL_PATH
- :689 LARGE_TRY_BLOCK
- :848 GENERIC_CATCH
- :2302 GENERIC_CATCH
- :2334 GENERIC_CATCH
src/services/worker/SDKAgent.ts (1 issue)
- :481 GENERIC_CATCH
src/services/worker/GeminiAgent.ts (1 issue)
- :138 LARGE_TRY_BLOCK
src/services/worker/OpenRouterAgent.ts (1 issue)
- :87 LARGE_TRY_BLOCK
src/services/infrastructure/ProcessManager.ts (20 issues)
- :56 LARGE_TRY_BLOCK
- :69 NO_LOGGING_IN_CATCH
- :205 GENERIC_CATCH
- :219 GENERIC_CATCH
- :263 GENERIC_CATCH
- :290 GENERIC_CATCH
- :307 GENERIC_CATCH
- :307 NO_LOGGING_IN_CATCH (APPROVED OVERRIDE exists — review)
- :375 LARGE_TRY_BLOCK
- :443 GENERIC_CATCH
- :470 GENERIC_CATCH
- :479 GENERIC_CATCH
- :525 LARGE_TRY_BLOCK
- :608 GENERIC_CATCH
- :628 GENERIC_CATCH
- :636 GENERIC_CATCH
- :751 LARGE_TRY_BLOCK
- :828 GENERIC_CATCH
- :899 GENERIC_CATCH
- :963 NO_LOGGING_IN_CATCH
- :963 GENERIC_CATCH
- :986 NO_LOGGING_IN_CATCH
- :1035 GENERIC_CATCH
src/services/infrastructure/HealthMonitor.ts (3 issues)
- :56 NO_LOGGING_IN_CATCH
- :93 GENERIC_CATCH
- :168 GENERIC_CATCH
src/services/infrastructure/WorktreeAdoption.ts (3 issues)
- :253 LARGE_TRY_BLOCK
- :285 GENERIC_CATCH
- :301 GENERIC_CATCH
src/services/worker/SessionManager.ts (5 issues)
- :72 NO_LOGGING_IN_CATCH
- :294 GENERIC_CATCH
- :345 GENERIC_CATCH
- :399 GENERIC_CATCH
- :471 GENERIC_CATCH
src/services/worker/ProcessRegistry.ts (2 issues)
- :398 NO_LOGGING_IN_CATCH
- :497 GENERIC_CATCH
src/services/worker/SearchManager.ts (8 issues)
- :442 LARGE_TRY_BLOCK
- :458 GENERIC_CATCH
- :692 LARGE_TRY_BLOCK
- :726 GENERIC_CATCH
- :766 LARGE_TRY_BLOCK
- :794 GENERIC_CATCH
- :1375 GENERIC_CATCH
- :1390 GENERIC_CATCH
src/services/worker/BranchManager.ts (5 issues)
- :121 LARGE_TRY_BLOCK
- :139 GENERIC_CATCH
- :244 GENERIC_CATCH
- :269 LARGE_TRY_BLOCK
- :301 GENERIC_CATCH
src/services/worker/SettingsManager.ts (1 issue)
- :45 GENERIC_CATCH
src/services/worker/PaginationHelper.ts (1 issue)
- :57 GENERIC_CATCH
src/services/worker/knowledge/KnowledgeAgent.ts (4 issues)
- :94 GENERIC_CATCH
- :133 GENERIC_CATCH
- :206 GENERIC_CATCH
- :261 GENERIC_CATCH
src/services/worker/knowledge/CorpusStore.ts (2 issues)
- :48 GENERIC_CATCH
- :75 GENERIC_CATCH
src/services/worker/knowledge/CorpusBuilder.ts (1 issue)
- :26 NO_LOGGING_IN_CATCH
src/services/worker/http/BaseRouteHandler.ts (1 issue)
- :29 GENERIC_CATCH
src/services/worker/http/routes/SearchRoutes.ts (2 issues)
- :272 LARGE_TRY_BLOCK
- :297 GENERIC_CATCH
src/services/worker/http/routes/SettingsRoutes.ts (1 issue)
- :76 GENERIC_CATCH
src/services/worker/http/routes/SessionRoutes.ts (5 issues)
- :223 PROMISE_CATCH_NO_LOGGING
- :259 GENERIC_CATCH
- :288 LARGE_TRY_BLOCK
- :589 LARGE_TRY_BLOCK
- :643 GENERIC_CATCH
src/services/worker/http/routes/CorpusRoutes.ts (1 issue)
- :96 NO_LOGGING_IN_CATCH
src/services/worker/http/routes/ViewerRoutes.ts (1 issue)
- :74 NO_LOGGING_IN_CATCH
src/services/worker/search/strategies/ChromaSearchStrategy.ts (2 issues)
- :66 LARGE_TRY_BLOCK
- :140 GENERIC_CATCH
src/services/worker/search/strategies/HybridSearchStrategy.ts (6 issues)
- :71 LARGE_TRY_BLOCK
- :113 GENERIC_CATCH
- :137 LARGE_TRY_BLOCK
- :178 GENERIC_CATCH
- :204 LARGE_TRY_BLOCK
- :244 GENERIC_CATCH
src/services/worker/search/strategies/SQLiteSearchStrategy.ts (2 issues)
- :67 LARGE_TRY_BLOCK
- :99 GENERIC_CATCH
src/services/queue/SessionQueueProcessor.ts (2 issues)
- :37 LARGE_TRY_BLOCK
- :67 GENERIC_CATCH
src/services/sync/ChromaMcpManager.ts (6 issues)
- :79 GENERIC_CATCH
- :310 NO_LOGGING_IN_CATCH
- :325 NO_LOGGING_IN_CATCH
- :344 GENERIC_CATCH
- :397 NO_LOGGING_IN_CATCH
- :411 NO_LOGGING_IN_CATCH
src/services/sync/ChromaSync.ts (5 issues)
- :565 LARGE_TRY_BLOCK
- :731 LARGE_TRY_BLOCK
- :788 ERROR_STRING_MATCHING
- :789 ERROR_STRING_MATCHING
- :828 GENERIC_CATCH
src/services/context/ContextBuilder.ts (1 issue)
- :52 GENERIC_CATCH
src/services/context/ObservationCompiler.ts (2 issues)
- :228 LARGE_TRY_BLOCK
- :248 GENERIC_CATCH
src/services/server/Server.ts (3 issues)
- :211 LARGE_TRY_BLOCK
- :235 NO_LOGGING_IN_CATCH
- :235 GENERIC_CATCH
src/services/worker-spawner.ts (1 issue)
- :56 NO_LOGGING_IN_CATCH
src/services/smart-file-read/search.ts (2 issues)
- :81 NO_LOGGING_IN_CATCH
- :117 NO_LOGGING_IN_CATCH
src/services/smart-file-read/parser.ts (5 issues)
- :162 NO_LOGGING_IN_CATCH
- :277 NO_LOGGING_IN_CATCH
- :284 NO_LOGGING_IN_CATCH
- :553 NO_LOGGING_IN_CATCH
- :588 NO_LOGGING_IN_CATCH
src/services/sqlite/migrations/runner.ts (4 issues)
- :421 LARGE_TRY_BLOCK
- :449 GENERIC_CATCH
- :661 LARGE_TRY_BLOCK
- :817 GENERIC_CATCH
src/services/sqlite/migrations.ts (1 issue)
- :381 NO_LOGGING_IN_CATCH
src/services/sqlite/observations/files.ts (1 issue)
- :20 NO_LOGGING_IN_CATCH
src/services/sqlite/timeline/queries.ts (2 issues)
- :114 GENERIC_CATCH
- :146 GENERIC_CATCH
src/services/sqlite/SessionSearch.ts (5 issues)
- :77 LARGE_TRY_BLOCK
- :161 GENERIC_CATCH
- :176 NO_LOGGING_IN_CATCH
- :384 NO_LOGGING_IN_CATCH
- :402 NO_LOGGING_IN_CATCH
src/services/transcripts/watcher.ts (4 issues)
- :46 NO_LOGGING_IN_CATCH
- :155 NO_LOGGING_IN_CATCH
- :183 NO_LOGGING_IN_CATCH
- :219 GENERIC_CATCH
src/services/transcripts/processor.ts (3 issues)
- :280 NO_LOGGING_IN_CATCH
- :325 LARGE_TRY_BLOCK
- :355 LARGE_TRY_BLOCK
src/services/transcripts/field-utils.ts (1 issue)
- :145 NO_LOGGING_IN_CATCH
src/services/integrations/CursorHooksInstaller.ts (11 issues)
- :118 GENERIC_CATCH
- :260 GENERIC_CATCH
- :311 LARGE_TRY_BLOCK
- :381 GENERIC_CATCH
- :402 LARGE_TRY_BLOCK
- :419 GENERIC_CATCH
- :459 LARGE_TRY_BLOCK
- :503 GENERIC_CATCH
- :538 LARGE_TRY_BLOCK
- :565 NO_LOGGING_IN_CATCH
- :602 GENERIC_CATCH
src/services/integrations/GeminiCliHooksInstaller.ts (6 issues)
- :164 GENERIC_CATCH
- :289 LARGE_TRY_BLOCK
- :334 GENERIC_CATCH
- :350 LARGE_TRY_BLOCK
- :403 GENERIC_CATCH
- :427 NO_LOGGING_IN_CATCH
- :427 GENERIC_CATCH
src/services/integrations/OpenCodeInstaller.ts (3 issues)
- :166 LARGE_TRY_BLOCK
- :214 LARGE_TRY_BLOCK
- :312 LARGE_TRY_BLOCK
src/services/integrations/OpenClawInstaller.ts (2 issues)
- :149 NO_LOGGING_IN_CATCH
- :253 LARGE_TRY_BLOCK
src/services/integrations/WindsurfHooksInstaller.ts (13 issues)
- :88 GENERIC_CATCH
- :152 GENERIC_CATCH
- :237 GENERIC_CATCH
- :289 LARGE_TRY_BLOCK
- :321 GENERIC_CATCH
- :337 LARGE_TRY_BLOCK
- :352 GENERIC_CATCH
- :386 LARGE_TRY_BLOCK
- :409 NO_LOGGING_IN_CATCH
- :409 GENERIC_CATCH
- :448 LARGE_TRY_BLOCK
- :459 NO_LOGGING_IN_CATCH
src/services/integrations/McpIntegrations.ts (4 issues)
- :108 LARGE_TRY_BLOCK
- :148 GENERIC_CATCH
- :277 LARGE_TRY_BLOCK
- :337 GENERIC_CATCH
src/services/integrations/CodexCliInstaller.ts (9 issues)
- :69 GENERIC_CATCH
- :138 LARGE_TRY_BLOCK
- :161 GENERIC_CATCH
- :187 LARGE_TRY_BLOCK
- :216 GENERIC_CATCH
- :237 LARGE_TRY_BLOCK
- :265 GENERIC_CATCH
- :291 LARGE_TRY_BLOCK
- :337 NO_LOGGING_IN_CATCH
src/services/domain/ModeManager.ts (3 issues)
- :146 GENERIC_CATCH
- :163 GENERIC_CATCH
- :173 GENERIC_CATCH
src/supervisor/process-registry.ts (5 issues)
- :35 NO_LOGGING_IN_CATCH
- :35 GENERIC_CATCH
- :68 GENERIC_CATCH
- :170 GENERIC_CATCH
- :197 GENERIC_CATCH
src/supervisor/shutdown.ts (6 issues)
- :38 GENERIC_CATCH
- :52 GENERIC_CATCH
- :71 GENERIC_CATCH
- :94 GENERIC_CATCH
- :139 GENERIC_CATCH
- :154 NO_LOGGING_IN_CATCH
src/supervisor/index.ts (2 issues)
- :72 GENERIC_CATCH
- :164 GENERIC_CATCH
src/cli/hook-command.ts (1 issue)
- :75 LARGE_TRY_BLOCK
src/cli/stdin-reader.ts (4 issues)
- :32 NO_LOGGING_IN_CATCH
- :52 NO_LOGGING_IN_CATCH
- :131 LARGE_TRY_BLOCK
- :170 NO_LOGGING_IN_CATCH
src/cli/claude-md-commands.ts (12 issues)
- :79 LARGE_TRY_BLOCK
- :97 GENERIC_CATCH
- :144 NO_LOGGING_IN_CATCH
- :190 NO_LOGGING_IN_CATCH
- :203 NO_LOGGING_IN_CATCH
- :319 LARGE_TRY_BLOCK
- :345 NO_LOGGING_IN_CATCH
- :345 GENERIC_CATCH
- :357 LARGE_TRY_BLOCK
- :430 GENERIC_CATCH
- :508 LARGE_TRY_BLOCK
- :525 GENERIC_CATCH
src/cli/handlers/session-complete.ts (2 issues)
- :38 LARGE_TRY_BLOCK
- :58 GENERIC_CATCH
src/cli/handlers/user-message.ts (1 issue)
- :28 LARGE_TRY_BLOCK
src/cli/handlers/context.ts (1 issue)
- :48 LARGE_TRY_BLOCK
src/cli/handlers/file-context.ts (3 issues)
- :202 NO_LOGGING_IN_CATCH
- :202 GENERIC_CATCH
- :221 LARGE_TRY_BLOCK
src/cli/handlers/summarize.ts (1 issue)
- :111 LARGE_TRY_BLOCK
src/cli/handlers/session-init.ts (1 issue)
- :134 LARGE_TRY_BLOCK
src/cli/handlers/file-edit.ts (1 issue)
- :41 LARGE_TRY_BLOCK
src/cli/handlers/observation.ts (1 issue)
- :50 LARGE_TRY_BLOCK
src/ui/viewer/hooks/useStats.ts (1 issue)
- :13 GENERIC_CATCH
src/ui/viewer/hooks/useTheme.ts (2 issues)
- :19 GENERIC_CATCH
- :64 GENERIC_CATCH
src/ui/viewer/hooks/useContextPreview.ts (3 issues)
- :40 LARGE_TRY_BLOCK
- :63 GENERIC_CATCH
- :108 NO_LOGGING_IN_CATCH
src/bin/import-xml-observations.ts (7 issues)
- :62 LARGE_TRY_BLOCK
- :134 LARGE_TRY_BLOCK
- :152 GENERIC_CATCH
- :167 LARGE_TRY_BLOCK
- :183 GENERIC_CATCH
- :329 GENERIC_CATCH
- :361 GENERIC_CATCH
src/utils/project-filter.ts (1 issue)
- :66 NO_LOGGING_IN_CATCH
src/utils/worktree.ts (2 issues)
- :41 NO_LOGGING_IN_CATCH
- :55 NO_LOGGING_IN_CATCH
src/utils/claude-md-utils.ts (2 issues)
- :442 LARGE_TRY_BLOCK
- :475 GENERIC_CATCH
src/utils/logger.ts (5 issues)
- :63 GENERIC_CATCH
- :87 NO_LOGGING_IN_CATCH
- :87 GENERIC_CATCH
- :155 NO_LOGGING_IN_CATCH
- :292 GENERIC_CATCH
src/utils/json-utils.ts (1 issue)
- :24 GENERIC_CATCH
src/utils/agents-md-utils.ts (1 issue)
- :34 GENERIC_CATCH
src/shared/timeline-formatting.ts (1 issue)
- :19 GENERIC_CATCH
src/shared/plugin-state.ts (1 issue)
- :25 NO_LOGGING_IN_CATCH
src/shared/worker-utils.ts (2 issues)
- :150 GENERIC_CATCH
- :179 LARGE_TRY_BLOCK
src/shared/SettingsDefaultsManager.ts (2 issues)
- :224 GENERIC_CATCH
- :244 GENERIC_CATCH
src/shared/EnvManager.ts (3 issues)
- :124 GENERIC_CATCH
- :134 LARGE_TRY_BLOCK
- :186 GENERIC_CATCH
src/shared/paths.ts (1 issue)
- :149 GENERIC_CATCH
src/sdk/prompts.ts (2 issues)
- :112 GENERIC_CATCH
- :121 GENERIC_CATCH
src/npx-cli/utils/bun-resolver.ts (1 issue)
- :82 NO_LOGGING_IN_CATCH
src/npx-cli/commands/install.ts (4 issues)
- :131 NO_LOGGING_IN_CATCH
- :375 NO_LOGGING_IN_CATCH
- :412 NO_LOGGING_IN_CATCH
- :501 NO_LOGGING_IN_CATCH
src/npx-cli/commands/uninstall.ts (1 issue)
- :123 NO_LOGGING_IN_CATCH
src/npx-cli/commands/runtime.ts (2 issues)
- :157 LARGE_TRY_BLOCK
- :177 GENERIC_CATCH
src/npx-cli/commands/ide-detection.ts (2 issues)
- :41 NO_LOGGING_IN_CATCH
- :56 NO_LOGGING_IN_CATCH
src/servers/mcp-server.ts (4 issues)
- :111 LARGE_TRY_BLOCK
- :156 LARGE_TRY_BLOCK
- :198 GENERIC_CATCH
- :232 GENERIC_CATCH
src/integrations/opencode-plugin/index.ts (3 issues)
- :108 LARGE_TRY_BLOCK
- :342 LARGE_TRY_BLOCK
- :357 NO_LOGGING_IN_CATCH