[dead-code] chore: remove dead functions — 4 functions removed#25798
[dead-code] chore: remove dead functions — 4 functions removed#25798
Conversation
Remove unreachable Go functions identified by the deadcode static analyzer: - ReadFileFromHEAD (pkg/gitutil/gitutil.go) - normalizeContainerPins + containerPinRE (pkg/workflow/compiler.go) - ResolveAgentFilePath (pkg/workflow/engine_helpers.go) - BuildInvalidAgentPathStep (pkg/workflow/engine_helpers.go) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
💥 Automated smoke test review - all systems nominal! This PR removes dead code functions across gitutil, compiler.go, and engine_helpers.go. The changes look clean and focused.
💥 [THE END] — Illustrated by Smoke Claude · ● 202.5K
| return ReadFileFromHEADWithRoot(filePath, gitRoot) | ||
| } | ||
|
|
||
| // ReadFileFromHEADWithRoot is like ReadFileFromHEAD but accepts a pre-computed git |
There was a problem hiding this comment.
✅ Good cleanup — ReadFileFromHEAD was a thin wrapper around ReadFileFromHEADWithRoot. Removing the wrapper reduces the public API surface and makes callers use the more explicit version directly. This is a clean dead-code removal.
| @@ -35,17 +35,6 @@ func normalizeHeredocDelimiters(content string) string { | |||
| return heredocDelimiterRE.ReplaceAllString(content, "GH_AW_${1}_NORM_EOF") | |||
| } | |||
There was a problem hiding this comment.
✅ Removing containerPinRE and normalizeContainerPins here makes sense if they're no longer used. Worth confirming no test helpers or other callers reference these functions before finalizing the PR.
There was a problem hiding this comment.
Pull request overview
Removes dead/unreachable Go helpers identified by deadcode, and keeps WASM golden tests stable by moving container pin normalization into the test.
Changes:
- Removed unused helpers and their dedicated tests (
ReadFileFromHEAD,ResolveAgentFilePath,BuildInvalidAgentPathStep, container pin normalizer). - Inlined container pin normalization into
wasm_golden_test.govia a test-local regex to preserve golden stability.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/wasm_golden_test.go | Adds a test-local regex to strip @sha256: digest pins during golden comparison |
| pkg/workflow/engine_helpers.go | Removes unused agent-path helpers |
| pkg/workflow/engine_helpers_test.go | Removes tests that exclusively covered the deleted agent-path helper |
| pkg/workflow/compiler.go | Removes unused container pin normalization helper/regex |
| pkg/gitutil/gitutil.go | Removes unused ReadFileFromHEAD wrapper |
| pkg/gitutil/gitutil_test.go | Removes tests that exclusively covered the deleted wrapper |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 6/6 changed files
- Comments generated: 1
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| // containerPinRE matches Docker image digest pins of the form @sha256:<64 hex chars>. |
There was a problem hiding this comment.
Comment refers to containerPinRE, but the actual regex variable here is testContainerPinRE. This can be confusing when grepping or when reading the test; consider updating the comment to match the identifier (or rename the variable/comment consistently).
| // containerPinRE matches Docker image digest pins of the form @sha256:<64 hex chars>. | |
| // testContainerPinRE matches Docker image digest pins of the form @sha256:<64 hex chars>. |
🧪 Test Quality Sentinel ReportTest Quality Score: N/A (Pure deletion PR)✅ Excellent — no deficiencies detected
Summary of Test ChangesThis PR removes 4 dead production functions and their corresponding tests. All test deletions are correct and appropriate — no orphaned test code remains.
Notable Quality ObservationsThe deleted tests were well-written: The Language SupportTests analyzed:
Verdict
📖 Understanding Test ClassificationsDesign Tests (High Value) verify what the system does:
Implementation Tests (Low Value) verify how the system does it:
Goal: Shift toward tests that describe the system's behavioral contract — the promises it makes to its users and collaborators.
|
Dead Code Removal
This PR removes unreachable Go functions identified by the
deadcodestatic analyzer.Functions Removed
ReadFileFromHEADpkg/gitutil/gitutil.gonormalizeContainerPins+containerPinREpkg/workflow/compiler.goResolveAgentFilePathpkg/workflow/engine_helpers.goBuildInvalidAgentPathSteppkg/workflow/engine_helpers.goTests Removed
TestReadFileFromHEAD— exclusively tested the deletedReadFileFromHEADfunctionTestReadFileFromHEADWithRoot/returns same result as ReadFileFromHEAD— sub-test that called the deleted functionTestResolveAgentFilePath— exclusively tested the deletedResolveAgentFilePathfunctionTestResolveAgentFilePathFormat— exclusively tested the deletedResolveAgentFilePathfunctionTestShellVariableExpansionInAgentPath— exclusively tested the deletedResolveAgentFilePathfunctionThe container pin normalization regex was inlined into
wasm_golden_test.goas a test-local variable (testContainerPinRE) since it is still needed for golden test stability (native compilation includes@sha256:pins; WASM does not).Verification
go build ./...— passesgo vet ./...— passesgo vet -tags=integration ./...— passesmake fmt— Go code formatted (fmt-cjs pre-existing failure unrelated to this change)go test ./pkg/gitutil/... ./pkg/workflow/...— passesDead Function Count
Automated by Dead Code Removal workflow — https://github.com/github/gh-aw/actions/runs/24281896384
✨ PR Review Safe Output Test - Run 24282404926