Skip to content

refactor(symbols): decompose god class, extract shared utilities#83

Merged
zbigniewsobiecki merged 1 commit intodevfrom
feature/refactor-symbols-show-god-class
Apr 7, 2026
Merged

refactor(symbols): decompose god class, extract shared utilities#83
zbigniewsobiecki merged 1 commit intodevfrom
feature/refactor-symbols-show-god-class

Conversation

@aaight
Copy link
Copy Markdown
Collaborator

@aaight aaight commented Apr 7, 2026

Summary

Refactors the 724-line symbols/show.ts god command and eliminates duplicated patterns found across the codebase.

  • Extracts resolveFileId shared helper — Consolidates the repeated getIdByPath(toRelativePath(...)) ?? getIdByPath(...) pattern from 5 files into a single src/commands/_shared/file-resolver.ts utility
  • Decomposes symbols/show.ts into three focused files: a data-gathering class (_show-data.ts), a renderer class (_show-renderer.ts), and a thin orchestrator (~95 lines, down from 724)
  • De-duplicates countArguments — Extracts the identical function from reference-extractor.ts and pure-check.ts into src/parser/_shared/ast-utils.ts
  • Adds 22 new unit tests for resolveFileId and SymbolShowDataGatherer

Files changed

New files

  • src/commands/_shared/file-resolver.ts — shared resolveFileId helper
  • src/commands/symbols/_show-data.tsSymbolShowDataGatherer class + typed interfaces (SymbolShowData, FileShowData)
  • src/commands/symbols/_show-renderer.tsSymbolShowRenderer class
  • src/parser/_shared/ast-utils.ts — shared countArguments utility
  • test/commands/_shared/file-resolver.test.ts — unit tests for resolveFileId
  • test/commands/symbols/show-data.test.ts — unit tests for SymbolShowDataGatherer

Modified files

  • src/commands/symbols/show.ts — reduced to ~95-line thin orchestrator
  • src/commands/_shared/index.ts — exports resolveFileId
  • src/commands/files/imports.ts, imported-by.ts, show.ts — use resolveFileId
  • src/commands/symbols/list.ts — uses resolveFileId
  • src/parser/reference-extractor.ts — imports countArguments from shared module
  • src/commands/llm/_shared/pure-check.ts — imports countArguments from shared module

Test plan

  • All 22 new tests pass
  • All pre-existing passing tests continue to pass
  • TypeScript compilation passes with zero errors
  • Biome lint passes with zero errors

Card

https://trello.com/c/69d54e09708468ab629905e2

- Extract resolveFileId helper from 5+ files into _shared/file-resolver.ts
- Decompose 724-line symbols/show.ts into data-gatherer + renderer + thin orchestrator
- Extract duplicate countArguments into src/parser/_shared/ast-utils.ts
- Add 22 new unit tests for resolveFileId and SymbolShowDataGatherer

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 37.83784% with 299 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/commands/symbols/_show-renderer.ts 0.00% 183 Missing ⚠️
src/commands/symbols/_show-data.ts 63.67% 93 Missing ⚠️
src/commands/symbols/show.ts 0.00% 18 Missing ⚠️
src/commands/symbols/list.ts 0.00% 2 Missing ⚠️
src/commands/files/imported-by.ts 0.00% 1 Missing ⚠️
src/commands/files/imports.ts 0.00% 1 Missing ⚠️
src/commands/files/show.ts 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Collaborator

@nhopeatall nhopeatall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test

Copy link
Copy Markdown
Collaborator

@nhopeatall nhopeatall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — Clean, well-executed decomposition of a 724-line god class into focused modules with proper shared utility extraction.

Verified:

  • resolveFileId is behaviorally equivalent to the inline patterns it replaces across all 5 call sites
  • countArguments extraction is identical between the two former copies
  • JSON output shape is preserved: the new inline module mapping matches what formatModuleRef returned
  • The SymbolShowRenderer output matches the old rendering methods line-for-line
  • CI green (lint + tests + type-check)

The data-gatherer/renderer split makes SymbolShowDataGatherer independently testable (demonstrated by the 22 new tests), which is a meaningful improvement over the old monolithic command class.

@zbigniewsobiecki zbigniewsobiecki merged commit 823ef1c into dev Apr 7, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants