-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Closed
Labels
AnalysisIssues related to static analysis (vet, x/tools/go/analysis)Issues related to static analysis (vet, x/tools/go/analysis)FrozenDueToAgeProposalProposal-Accepted
Milestone
Description
The golang.org/x/tools/internal/cmd/deadcode command reports dead code, that is, functions not reachable by a sequence of calls from main, even through reflection, based on an RTA-based call graph. We have found it useful for identifying orphaned bits of code in x/tools and we imagine others might find it useful too. We propose to publish it at cmd/deadcode in the same repo.
This is an example of the tool in action, showing functions in x/tools not reachable from gopls' main or any of its tests, and suppressing functions in generated source files.
xtools$ deadcode -test ./gopls/...
golang.org/x/tools/gopls/internal/lsp
openClientEditor
golang.org/x/tools/gopls/internal/lsp/cache
(fileLoadScope).aScope
(packageLoadScope).aScope
(moduleLoadScope).aScope
(viewLoadScope).aScope
golang.org/x/tools/gopls/internal/lsp/debug/log
(Level).Log
(Level).Logf
golang.org/x/tools/gopls/internal/lsp/filecache
SetBudget
golang.org/x/tools/gopls/internal/lsp/regtest
(State).outstandingWork
golang.org/x/tools/gopls/internal/lsp/source
WidestPackageForFile
golang.org/x/tools/gopls/internal/lsp/template
(*Parsed).WriteNode
(wrNode).writeNode
xtools$ deadcode -test -json ./gopls/...
[
{
"Path": "golang.org/x/tools/gopls/internal/lsp",
"Funcs": [
{
"Name": "golang.org/x/tools/gopls/internal/lsp.openClientEditor",
"RelName": "openClientEditor",
"Posn": "/Users/adonovan/w/xtools/gopls/internal/lsp/command.go:1178:6",
"Generated": false
}
]
},
...
mateusz834, earthboundkid, bep, ericchiang, mvdan and 9 more
Metadata
Metadata
Assignees
Labels
AnalysisIssues related to static analysis (vet, x/tools/go/analysis)Issues related to static analysis (vet, x/tools/go/analysis)FrozenDueToAgeProposalProposal-Accepted