-
Notifications
You must be signed in to change notification settings - Fork 21.4k
Closed
Description
Continuing our CI linter efforts, it would be nice to have Go's deadcode
linter enabled on our CI infrastructure to detect and report leftover code from refactors. Enabling the linter is simple enough:
diff --git a/build/ci.go b/build/ci.go
index 0c825ef31..98289587c 100644
--- a/build/ci.go
+++ b/build/ci.go
@@ -323,7 +323,7 @@ func doLint(cmdline []string) {
build.MustRunCommand(filepath.Join(GOBIN, "gometalinter.v1"), "--install")
// Run fast linters batched together
- configs := []string{"--vendor", "--disable-all", "--enable=vet", "--enable=gofmt", "--enable=misspell"}
+ configs := []string{"--vendor", "--disable-all", "--enable=vet", "--enable=gofmt", "--enable=misspell", "--enable=deadcode"}
build.MustRunCommand(filepath.Join(GOBIN, "gometalinter.v1"), append(configs, packages...)...)
// Run slow linters one by one
Beside enabling the deadcode
linter, this task would entail looking though the generated warnings and fixing them. Note, some code is "dead", but shouldn't necessarily be deleted (e.g. the currently unused Ledger protocol constants)... for these, a nicer solution is needed so deadcode
remains silent, but the constants remain in the code nonetheless.
Currently reported issues are:
accounts/abi/numbers.go:53:1:warning: isSigned is unused (deadcode)
accounts/usbwallet/ledger.go:50:1:warning: ledgerP1ConfirmFetchAddress is unused (deadcode)
accounts/usbwallet/ledger.go:50:1:warning: ledgerP2ReturnAddressChainCode is unused (deadcode)
cmd/faucet/website.go:108:1:warning: MustAsset is unused (deadcode)
cmd/faucet/website.go:133:1:warning: AssetNames is unused (deadcode)
consensus/clique/clique.go:54:1:warning: blockPeriod is unused (deadcode)
consensus/ethash/algorithm.go:166:1:warning: prepare is unused (deadcode)
core/asm/compiler.go:270:1:warning: errExpBol is unused (deadcode)
core/asm/compiler.go:270:1:warning: errExpElementOrLabel is unused (deadcode)
core/types/block.go:89:1:warning: headerMarshaling is unused (deadcode)
core/types/log.go:59:1:warning: logMarshaling is unused (deadcode)
core/types/receipt.go:60:1:warning: receiptMarshaling is unused (deadcode)
core/types/transaction.go:35:1:warning: errNoSigner is unused (deadcode)
core/types/transaction.go:74:1:warning: txdataMarshaling is unused (deadcode)
core/vm/memory_table.go:68:1:warning: memoryCallCode is unused (deadcode)
core/vm/logger.go:70:1:warning: structLogMarshaling is unused (deadcode)
crypto/sha3/xor.go:16:1:warning: xorImplementationUnaligned is unused (deadcode)
core/chain_makers.go:34:1:warning: forkSeed is unused (deadcode)
core/chain_makers.go:232:1:warning: newCanonical is unused (deadcode)
core/genesis.go:89:1:warning: genesisSpecMarshaling is unused (deadcode)
core/tx_pool.go:38:1:warning: rmTxChanSize is unused (deadcode)
eth/config.go:118:1:warning: configMarshaling is unused (deadcode)
eth/downloader/downloader.go:72:1:warning: errInvalidBlock is unused (deadcode)
swarm/storage/netstore.go:80:1:warning: requesterCount is unused (deadcode)
swarm/storage/dbstore.go:41:1:warning: kpData is unused (deadcode)
p2p/peer.go:44:1:warning: peersMsg is unused (deadcode)
p2p/peer.go:44:1:warning: getPeersMsg is unused (deadcode)
p2p/message.go:117:1:warning: netWrapper is unused (deadcode)
p2p/server.go:38:1:warning: refreshPeersInterval is unused (deadcode)
p2p/server.go:38:1:warning: staticPeerCheckInterval is unused (deadcode)
p2p/discover/udp.go:50:1:warning: sendTimeout is unused (deadcode)
p2p/discover/node.go:415:1:warning: hashAtDistance is unused (deadcode)
les/sync.go:28:1:warning: minDesiredPeerCount is unused (deadcode)
les/bloombits.go:76:1:warning: bloomThrottling is unused (deadcode)
les/bloombits.go:76:1:warning: bloomConfirms is unused (deadcode)
les/serverpool.go:39:1:warning: pstatRecentAdjust is unused (deadcode)
les/serverpool.go:39:1:warning: peerSelectMinWeight is unused (deadcode)
p2p/discv5/udp.go:38:1:warning: errClockWarp is unused (deadcode)
p2p/discv5/udp.go:38:1:warning: errClosed is unused (deadcode)
p2p/discv5/udp.go:38:1:warning: errUnsolicitedReply is unused (deadcode)
p2p/discv5/udp.go:38:1:warning: errUnknownNode is unused (deadcode)
p2p/discv5/udp.go:38:1:warning: errTimeout is unused (deadcode)
p2p/discv5/udp.go:38:1:warning: errExpired is unused (deadcode)
p2p/discv5/udp.go:50:1:warning: sendTimeout is unused (deadcode)
p2p/discv5/udp.go:50:1:warning: ntpWarningCooldown is unused (deadcode)
p2p/discv5/udp.go:50:1:warning: ntpFailureThreshold is unused (deadcode)
p2p/discv5/table.go:35:1:warning: maxBondingPingPongs is unused (deadcode)
p2p/discv5/ntp.go:47:1:warning: checkClockDrift is unused (deadcode)
p2p/discv5/net.go:37:1:warning: errWrongAddress is unused (deadcode)
p2p/discv5/net.go:51:1:warning: testTopic is unused (deadcode)
p2p/discv5/net.go:828:1:warning: invalidEvent is unused (deadcode)
p2p/discv5/node.go:416:1:warning: hashAtDistance is unused (deadcode)
swarm/network/kademlia/kademlia.go:310:1:warning: sortedByDistanceTo is unused (deadcode)
synctest/main.go:12:1:warning: emptyRoot is unused (deadcode)
whisper/whisperv2/topic.go:107:1:warning: newTopicMatcherFromBinary is unused (deadcode)
whisper/whisperv2/topic.go:117:1:warning: newTopicMatcherFromStrings is unused (deadcode)