Skip to content

Duplicate call-ref/tests rendering logic: presentation/audit.ts vs presentation/queries-cli/inspect.ts #1772

Description

@carlos-alm

Found during Titan Paradigm grind (phase 25, processing the fail-fix commit for src/presentation/audit.ts).

Phase 25's decomposition of renderAuditFunction in src/presentation/audit.ts extracted renderCallRefs(label, refs) (used for both the "Calls" and "Called by" sections) and renderRelatedTests(fn). Both are near-identical in shape to code that already existed in renderExplainEdges in src/presentation/queries-cli/inspect.ts:479-501:

  • audit.ts renderCallRefs: \n {label} ({refs.length}): then {icon} {name} {file}:{line} per entry — no indent support, no "no edges" fallback.
  • inspect.ts renderExplainEdges (calls/called-by portion): \n{indent} Calls ({callees.length}): / \n{indent} Called by ({callers.length}):, same per-entry format but with an indent parameter (for recursive nested rendering) and a (no call edges found -- may be invoked dynamically or via re-exports) fallback when both lists are empty.
  • Same overlap for the "Tests" section: audit.ts renderRelatedTests renders \n Tests ({n}):; inspect.ts renders \n{indent} Tests ({n} {file|files}): with singular/plural label.

This is the same category of duplication as #1756 (impact-level rendering, also found in phase 25) but for the calls/called-by/tests sections instead. Unifying these into one shared helper would require generalizing for indent, the "no edges" fallback, and tests-label pluralization — each a small output-format decision that needs explicit sign-off since it would change codegraph audit or codegraph explain/inspect output.

Left unaddressed during grind because phase 25's own dead-symbol scope was empty (no dead functions/constants surfaced in presentation/audit.ts, features/audit.ts, or types.ts) and this is a pre-existing cross-file duplication, not a symbol introduced dead by the phase — grind only wires/removes dead symbols, it doesn't restructure live, working code across command surfaces. Filing so it isn't lost.

Suggested fix: decide on one canonical format (indent-aware, with the "no edges" fallback and pluralized tests label, since inspect.ts's version is the superset), extract a shared renderCallRefsSection(label, refs, opts) / renderRelatedTestsSection(tests, opts) helper (e.g. in a small shared presentation module), and adopt it in both presentation/audit.ts and presentation/queries-cli/inspect.ts in a dedicated PR, with explicit sign-off on any output format changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    follow-upDeferred work from PR reviews that needs tracking

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions