Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 21
Delete the dead TUI, and add a check that could have seen it#653
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -190,6 +190,56 @@ bench-compare: | ||
| @command -v benchstat >/dev/null 2>&1 || go install golang.org/x/perf/cmd/benchstat@latest | ||
| benchstat benchmarks-baseline.txt benchmarks-current.txt | ||
| # Report unreachable code, whole-program, from the production binary's main. | ||
| # | ||
| # NOT a gate, and not wired into `make check`. golangci's `unused` (staticcheck | ||
| # U1000) runs per-package and treats every exported identifier in a non-main | ||
| # package as used by definition, which is why 602 lines of exported, zero-caller | ||
| # internal/tui API survived it — no configuration fixes that, the analysis | ||
| # cannot see across package boundaries. deadcode can, because it starts from a | ||
| # main and follows the call graph. | ||
| # | ||
| # Which main matters. Only main packages are roots, so `deadcode ./...` loads | ||
| # every package and then reports everything no main reaches as unreachable — | ||
| # 1100+ of its 1250 lines here are the dev-tagged workspace tree, which the | ||
| # untagged build genuinely cannot reach. True, and useless. Naming the binary | ||
| # gives two answers worth reading instead: | ||
| # | ||
| # deadcode ./cmd/basecamp what a released basecamp can never run | ||
| # deadcode -tags=dev ./cmd/basecamp the same, with the dev `basecamp tui` tree | ||
| # | ||
| # `go run` the pinned version rather than trusting whatever `deadcode` happens | ||
| # to be on PATH; an unpinned tool makes the output depend on the machine. | ||
| # | ||
| # ONE PLATFORM AT A TIME. deadcode analyzes the current GOOS/GOARCH, and this | ||
| # repo releases darwin, linux, windows, freebsd and openbsd. So a host run is | ||
| # evidence about the host and nothing else, in both directions: code behind | ||
| # another platform's build tag is never loaded, and a function whose only caller | ||
| # sits behind one looks unreachable here. Measured on this tree: 78 findings for | ||
| # linux and darwin, 77 for windows, with harden_unix.go's ownedByUID present | ||
| # only in the unix reports. | ||
| # | ||
| # To check another target, install the tool for the host and set GOOS for the | ||
| # analysis — `GOOS=windows go run ...` cross-compiles the tool itself and dies | ||
| # with an exec format error: | ||
| # | ||
| # go install golang.org/x/tools/cmd/deadcode@v0.40.0 | ||
| # GOOS=windows deadcode ./cmd/basecamp | ||
| # | ||
| # Read the output before acting on it. A zero-caller exported symbol is a | ||
| # candidate, not a verdict — some are a deliberate API surface, the -tags dev | ||
| # tree is legitimately partial, and a cross-platform deletion needs a run per | ||
| # target. Wiring a noisy check into CI is how a control nobody sized gets built. | ||
| DEADCODE := golang.org/x/tools/cmd/deadcode@v0.40.0 | ||
| .PHONY: deadcode | ||
| deadcode: check-toolchain | ||
jeremy marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| @echo "== shipped binary ==" | ||
| $(GOCMD) run $(DEADCODE) ./cmd/basecamp | ||
| @echo | ||
| @echo "== with -tags dev ==" | ||
| $(GOCMD) run $(DEADCODE) -tags=dev ./cmd/basecamp | ||
jeremy marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| # Guard against Go toolchain mismatch (mise environment) | ||
| .PHONY: check-toolchain | ||
| check-toolchain: | ||
| @@ -558,6 +608,7 @@ help: | ||
| @echo " fmt-check Check code formatting" | ||
| @echo " lint Run golangci-lint" | ||
| @echo " lint-actions Lint GitHub Actions workflows (actionlint + zizmor)" | ||
| @echo " deadcode Report unreachable code from the binary (report, not a gate)" | ||
| @echo " tidy-check Verify go.mod/go.sum are tidy" | ||
| @echo " check Run all checks (local CI gate)" | ||
| @echo " check-surface Verify committed .surface matches the command tree (TestSurfaceSnapshot)" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.