Skip to content

Remove dead Go code identified by deadcode analysis#2979

Merged
markphelps merged 3 commits intomainfrom
md/remove-dead-code
Apr 30, 2026
Merged

Remove dead Go code identified by deadcode analysis#2979
markphelps merged 3 commits intomainfrom
md/remove-dead-code

Conversation

@michaeldwan
Copy link
Copy Markdown
Member

Large chunks of Go code have accumulated with zero callers -- leftovers from feature removals (fast/monobase builds, old docker CLI client, cog migrate) and abstractions that were designed wider than what the CLI adopted.

Ran deadcode ./... across the repo, traced each hit back through git history to confirm it's genuinely orphaned, then removed everything that's safe to delete. ~1,870 lines gone across both commits.

What's removed:

  • pkg/web/, pkg/http/ -- Replicate API client for push telemetry (removed in first commit)
  • Fast-build leftovers: GenerateRequirements, CurrentRequirements, VersionSpecifier, CheckMajorOnly, CheckMajorMinorPatch, dockerignore.Walk, WriteIfDifferent
  • Old docker CLI client fragments: RingBufferWriter, DockerCommandFromEnvironment, isNetworkError
  • Config internals: parseFile, defaultConfig, DefaultBuildOptions, WithRequirementsFS, WithStrictDeprecations
  • Keepsake console port: FormatTime, Interactive/InteractiveBool, ParseLevel/MustParseLevel, Level.String, GetWidth, non-f Success/Error variants
  • Dead since 2021: entire pkg/util/shell/ package, WrapError, IsDir, IsExecutable, CopyFile, SHA256Hash*
  • Superseded: predict.NewInputs, predict.NewInputsWithBaseDir

What's kept (intentionally):

  • FromYAML -- explicitly designed as a test helper, used by 8+ config tests
  • PickFreePort -- deadcode false positive, called by registry_testhelpers
  • StandardPush, WithAuthConfig, WithHost -- may be needed again
  • GetEnvOrDefault, OverwriteYAML, RingBufferWriter... wait, that one's gone now
  • All dockertest/, registrytest/, registry_testhelpers/, integration-tests/harness/ -- test infrastructure, deadcode false positives

Tests that exercised removed functions were either removed or updated to use equivalent internal APIs. go mod tidy dropped github.com/xeonx/timeago.

Build passes, 0 lint issues, 1121 tests pass.

These packages were confirmed unreachable by deadcode analysis.
pkg/web (Replicate API client) and pkg/http (auth transport) lost
their callers when the push flow moved to the custom registry pusher.
Also removes the orphaned BuildInfo struct and Push function from
pkg/docker/push.go, and the WebHost/APIHost env helpers that only
those packages used.
… helpers, console/shell utils, predict inputs
Copy link
Copy Markdown
Contributor

@ask-bonk ask-bonk Bot left a comment

Choose a reason for hiding this comment

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

LGTM overall - this is a well-executed cleanup of genuinely dead code.

One minor observation:

The removal of InvalidLevel from the iota changes the integer values of the log levels. Previously:

  • InvalidLevel = -1
  • DebugLevel = 0
  • InfoLevel = 1

Now:

  • DebugLevel = 0
  • InfoLevel = 1

This is actually correct since InvalidLevel was unused, but worth noting that the underlying integer values haven't changed for the valid levels.

Build passes, tests pass (1121), lint clean. The go mod tidy removal of timeago is correct - it was only used by the deleted pkg/web/ client.

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk Bot commented Apr 30, 2026

Posted review to PR #2979: #2979 (review)

github run

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk Bot commented Apr 30, 2026

LGTM

github run

@michaeldwan michaeldwan marked this pull request as ready for review April 30, 2026 15:56
@michaeldwan michaeldwan requested a review from a team as a code owner April 30, 2026 15:56
@michaeldwan michaeldwan requested a review from markphelps April 30, 2026 15:58
Copy link
Copy Markdown
Contributor

@markphelps markphelps left a comment

Choose a reason for hiding this comment

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

i love the smell of deleted code in the morning

@markphelps markphelps added this pull request to the merge queue Apr 30, 2026
Merged via the queue into main with commit 643ad51 Apr 30, 2026
43 checks passed
@markphelps markphelps deleted the md/remove-dead-code branch April 30, 2026 17:51
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.

2 participants