Skip to content

[dead-code] chore: remove dead functions — 1 function removed#44330

Merged
pelikhan merged 1 commit into
mainfrom
dead-code/remove-renderMarkdownMetricsTrend-76dae1895bd7acd6
Jul 9, 2026
Merged

[dead-code] chore: remove dead functions — 1 function removed#44330
pelikhan merged 1 commit into
mainfrom
dead-code/remove-renderMarkdownMetricsTrend-76dae1895bd7acd6

Conversation

@github-actions

@github-actions github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Removes one dead unexported function and its corresponding test.

Changes

pkg/cli/audit_cross_run_render.go

  • Deleted renderMarkdownMetricsTrend(mt MetricsTrendData) — an unexported wrapper that forwarded to renderMarkdownMetricsTrendToWriter(os.Stdout, mt). The function had no callers and was dead code. The underlying renderMarkdownMetricsTrendToWriter is unchanged.

pkg/cli/audit_cross_run_test.go

  • Deleted TestRenderMarkdownMetricsTrend_IncludesTurnsWithoutTokens — the sole test for the removed function. The test captured stdout via os.Pipe(), exercised renderMarkdownMetricsTrend, and asserted markdown table output. Removed as it no longer has a subject.

Impact

  • No public API surface changed.
  • No runtime behaviour changed.
  • Reduces test surface that relied on os.Stdout redirection (fragile pattern).

Checklist

  • Dead code only — no logic modified
  • Corresponding test removed
  • No callers affected

Generated by PR Description Updater for #44330 · 30.8 AIC · ⌖ 6.2 AIC · ⊞ 4.7K ·

Remove renderMarkdownMetricsTrend which was unreachable (no non-test callers)
and its exclusive test TestRenderMarkdownMetricsTrend_IncludesTurnsWithoutTokens.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review July 9, 2026 01:10
Copilot AI review requested due to automatic review settings July 9, 2026 01:10
@pelikhan pelikhan merged commit e5bceb0 into main Jul 9, 2026
22 checks passed
@pelikhan pelikhan deleted the dead-code/remove-renderMarkdownMetricsTrend-76dae1895bd7acd6 branch July 9, 2026 01:11
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

PR Code Quality Reviewer completed the code quality review.

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR #44330 does not have the 'implementation' label and has 0 new lines of code in business logic directories (threshold: 100).

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Test Quality Sentinel completed test quality analysis.

No test files were added or modified in this PR. Test Quality Sentinel skipped. (PR removes 28 lines including 24 lines of test deletions from audit_cross_run_test.go, which is a dead-code cleanup, not new test coverage.)

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Removes a dead stdout wrapper function for rendering cross-run Markdown metrics and deletes the associated unit test that called it.

Changes:

  • Removed renderMarkdownMetricsTrend (stdout wrapper) in favor of using renderMarkdownMetricsTrendToWriter directly.
  • Removed TestRenderMarkdownMetricsTrend_IncludesTurnsWithoutTokens.
Show a summary per file
File Description
pkg/cli/audit_cross_run_render.go Removes an unused stdout wrapper around renderMarkdownMetricsTrendToWriter.
pkg/cli/audit_cross_run_test.go Deletes the only test that covered Markdown metrics “turns without tokens” output.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Low

Comment on lines 314 to 315

func TestRenderMarkdownMetricsTrend_IncludesTurnsWithoutTokens(t *testing.T) {
oldStdout := os.Stdout
r, w, err := os.Pipe()
require.NoError(t, err, "should create stdout pipe")
os.Stdout = w

renderMarkdownMetricsTrend(MetricsTrendData{
TotalTurns: 9,
AvgTurns: 4.5,
MaxTurns: 6,
})

w.Close()
os.Stdout = oldStdout

var buf bytes.Buffer
_, err = buf.ReadFrom(r)
require.NoError(t, err, "should read captured stdout")
output := buf.String()

assert.Contains(t, output, "## Metrics Trends", "Should render metrics section when turn metrics exist")
assert.Contains(t, output, "| Turns | 9 | 4.5 | — | 6 | — |", "Should render turns row without tokens")
}

func TestRenderPrettyMetricsTrend_IncludesDurationWithoutTokens(t *testing.T) {

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Review: Dead Code Removal

The change is clean and correct. renderMarkdownMetricsTrend was a trivial os.Stdout-bound wrapper with no remaining callers; removing it alongside its dedicated test is the right approach. The underlying renderMarkdownMetricsTrendToWriter remains intact and tested.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · 17.8 AIC · ⌖ 5.76 AIC · ⊞ 4.8K

@github-actions github-actions Bot mentioned this pull request Jul 9, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Skills-Based Review 🧠

Applied /codebase-design — this is a clean, risk-free dead-code removal.

📋 Key Themes & Highlights

Positive Highlights

  • renderMarkdownMetricsTrend had zero callers — confirmed dead; removal is correct
  • ✅ The ToWriter variant (renderMarkdownMetricsTrendToWriter) remains, is the better-designed function (injected io.Writer vs hard-coded os.Stdout), and is still exercised by higher-level tests
  • ✅ Removing the test that relied on stdout pipe-hijacking is a quality improvement — the underlying behaviour is covered by TestRenderCrossRunReportMarkdown via the ToWriter path
  • ✅ All verification checks pass (build, vet, fmt)

No actionable issues found.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · 17.9 AIC · ⌖ 6.56 AIC · ⊞ 6.6K
Comment /matt to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Dead code removal is correct; one test coverage gap needs attention

The renderMarkdownMetricsTrend wrapper has zero callers — removal is justified. The generated check runs confirm go build and go vet pass. One non-blocking issue flagged inline.

Review summary

What's good: The removal is clean — no stale imports, no lingering references, and the ...ToWriter variant retains its integration-level call path via renderCrossRunReportMarkdown.

Issue: TestRenderMarkdownMetricsTrend_IncludesTurnsWithoutTokens was the sole test exercising the TotalTurns > 0 && TotalTokens == 0 code path in renderMarkdownMetricsTrendToWriter. Deleting the wrapper does not justify deleting this branch coverage. The fix is a one-to-one test migration to call renderMarkdownMetricsTrendToWriter with an io.Writer instead of relying on the now-removed os.Stdout-swapping wrapper.

🔎 Code quality review by PR Code Quality Reviewer · 78.7 AIC · ⌖ 6.45 AIC · ⊞ 5.4K
Comment /review to run again

assert.Contains(t, output, "| Turns | 9 | 4.5 | — | 6 | — |", "Should render turns row without tokens")
}

func TestRenderPrettyMetricsTrend_IncludesDurationWithoutTokens(t *testing.T) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Test coverage gap: deleting this test removes the only coverage for the TotalTurns > 0 && TotalTokens == 0 branch in renderMarkdownMetricsTrendToWriter.

💡 Suggested fix

The test tested the now-dead wrapper (renderMarkdownMetricsTrend), but the interesting assertion — that the Turns row renders correctly when no token data exists — tests the underlying renderMarkdownMetricsTrendToWriter logic, which is still live. The wrapper removal does not justify deleting the coverage.

The remaining integration test TestRenderCrossRunReportMarkdown_IncludesNewSections always supplies both TotalTokens and TotalTurns, so it never exercises lines 79–82 of the render file:

if mt.TotalTurns > 0 {
    fmt.Fprintf(w, "| Turns | %d | %.1f | — | %d | — |\\n",
        mt.TotalTurns, mt.AvgTurns, mt.MaxTurns)
}

Instead of deleting, migrate the test to call renderMarkdownMetricsTrendToWriter directly:

func TestRenderMarkdownMetricsTrendToWriter_TurnsOnlyNoTokens(t *testing.T) {
    var buf bytes.Buffer
    renderMarkdownMetricsTrendToWriter(&buf, MetricsTrendData{
        TotalTurns: 9,
        AvgTurns:   4.5,
        MaxTurns:   6,
    })
    output := buf.String()
    assert.Contains(t, output, "## Metrics Trends", "Should render metrics section when turn metrics exist")
    assert.Contains(t, output, "| Turns | 9 | 4.5 | — | 6 | — |", "Should render turns row without tokens")
}

This also eliminates the flaky os.Stdout swap antipattern from the deleted test.

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

🎉 This pull request is included in a new release.

Release: v0.82.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants