[dead-code] chore: remove dead functions — 6 functions removed#24476
[dead-code] chore: remove dead functions — 6 functions removed#24476
Conversation
Remove unreachable Go functions identified by the deadcode static analyzer: - Coordinator.Stages (pkg/agentdrain/coordinator.go) - Coordinator.MinerForStage (pkg/agentdrain/coordinator.go) - Miner.PreTrainTemplate (pkg/agentdrain/pretrain.go) - Miner.PreTrainTemplates (pkg/agentdrain/pretrain.go) - Miner.PreTrainTemplateCounts (pkg/agentdrain/pretrain.go) - sortPinsByVersion (pkg/workflow/action_pins.go) Also remove exclusive test functions and update TestStageRouting to remove the MinerForStage section. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
💥 Automated smoke test review - all systems nominal!
💥 [THE END] — Illustrated by Smoke Claude · ● 182.6K
| @@ -52,25 +52,6 @@ func (c *Coordinator) AnalyzeEvent(evt AgentEvent) (*MatchResult, *AnomalyReport | |||
| return m.AnalyzeEvent(evt) | |||
There was a problem hiding this comment.
The removal of Stages() and MinerForStage() looks correct per the dead-code analysis. Consider adding a comment to AllClusters() clarifying it is now the primary iteration point for consumers that previously used Stages().
| @@ -144,25 +144,6 @@ func getActionPinsByRepo(repo string) []ActionPin { | |||
| return cachedActionPinsByRepo[repo] | |||
There was a problem hiding this comment.
Clean removal of sortPinsByVersion. Confirm that GetActionPin (the only caller of the sort logic) still handles multi-version repos correctly after this change — the inline sort logic should cover the same cases.
There was a problem hiding this comment.
Pull request overview
This PR removes unreachable Go code identified by a dead-code analyzer, including deleting an entire file (pretrain.go) whose exported methods were unused, and trimming now-obsolete tests.
Changes:
- Removed
sortPinsByVersionand its dedicated unit test. - Removed
Coordinator.Stages,Coordinator.MinerForStage, and pretrain-relatedMinermethods; deletedpkg/agentdrain/pretrain.go. - Updated
TestStageRoutingto stop relying on the removed coordinator API.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/action_pins.go | Removes unused sortPinsByVersion helper. |
| pkg/workflow/action_pins_test.go | Removes test that exclusively covered the deleted helper. |
| pkg/agentdrain/pretrain.go | Deletes file containing only dead pretrain helpers. |
| pkg/agentdrain/miner_test.go | Removes/updates tests that depended on removed dead methods. |
| pkg/agentdrain/coordinator.go | Removes unused coordinator methods (Stages, MinerForStage). |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 5/5 changed files
- Comments generated: 0
Dead Code Removal
This PR removes unreachable Go functions identified by the
deadcodestatic analyzer.Functions Removed
Coordinator.Stagespkg/agentdrain/coordinator.goCoordinator.MinerForStagepkg/agentdrain/coordinator.goMiner.PreTrainTemplatepkg/agentdrain/pretrain.goMiner.PreTrainTemplatespkg/agentdrain/pretrain.goMiner.PreTrainTemplateCountspkg/agentdrain/pretrain.gosortPinsByVersionpkg/workflow/action_pins.gopkg/agentdrain/pretrain.gowas deleted entirely since all its functions were dead.Tests Removed / Updated
TestPreTrainTemplate(pkg/agentdrain/miner_test.go) — deleted; exclusively tested the removed pretrain functionsTestSortPinsByVersion(pkg/workflow/action_pins_test.go) — deleted; exclusively testedsortPinsByVersionTestStageRouting(pkg/agentdrain/miner_test.go) — updated to removeMinerForStagecall sectionVerification
go build ./...— passesgo vet ./...— passesgo vet -tags=integration ./...— passesmake fmt— no changes neededgo test ./pkg/agentdrain/... ./pkg/workflow/...— passesDead Function Count
Automated by Dead Code Removal workflow — https://github.com/github/gh-aw/actions/runs/23978319418
✨ PR Review Safe Output Test - Run 23978813659