Skip to content
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

Enable deadcode linter on CI and fix reported errors #15473

Closed
karalabe opened this issue Nov 13, 2017 · 11 comments
Closed

Enable deadcode linter on CI and fix reported errors #15473

karalabe opened this issue Nov 13, 2017 · 11 comments

Comments

@karalabe
Copy link
Member

karalabe commented Nov 13, 2017

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)
@ferhatelmas
Copy link
Contributor

@karalabe Can I take this too ?

@karalabe
Copy link
Member Author

Sure!

ferhatelmas added a commit to ferhatelmas/go-ethereum that referenced this issue Nov 17, 2017
 * also fixes warnings generated by linter
 * fixes ethereum#15473
@vaibhavchellani
Copy link

should be closed now i guess @karalabe @ferhatelmas

@RichardH92
Copy link
Contributor

Can I work on this?

@ferhatelmas
Copy link
Contributor

ferhatelmas commented Feb 11, 2018

@RichardH92 there were some deficiencies with linter itself. However, for sure, see for yourself since there might be something I had missed at that time.

@cooganb
Copy link
Contributor

cooganb commented Mar 15, 2018

@karalabe Starting to look into if I can help at all! 🤓 🤓

thomasmodeneis added a commit to modeneis/go-ethereum that referenced this issue Apr 5, 2018
@thomasmodeneis
Copy link
Contributor

thomasmodeneis commented Apr 5, 2018

I started working on this, so far I enabled the linting on my fork.
I will start fixing the linting errs, but this may take some time.

Create WIP pull req #16446

@thomasmodeneis
Copy link
Contributor

this can now be closed.

@Dave2011
Copy link

Can this issue be closed?

@mattsilv
Copy link

@karalabe can this issue be closed?

@adamschmideg
Copy link
Contributor

#16446 got merged, closing this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants