From 003d15fa4b665fb2ec5b35da9008ebfc0a7c26d6 Mon Sep 17 00:00:00 2001 From: Sam Kleinman Date: Thu, 4 Nov 2021 12:44:13 +0100 Subject: [PATCH] lint: cleanup branch lint errors (#7238) --- .golangci.yml | 2 +- crypto/secp256k1/secp256k1_nocgo.go | 1 + internal/consensus/wal_fuzz.go | 1 + internal/libs/sync/deadlock.go | 1 + internal/libs/sync/sync.go | 1 + internal/mempool/ids.go | 2 +- internal/p2p/conn/conn_go110.go | 1 + internal/p2p/conn/conn_notgo110.go | 1 + internal/state/state.go | 4 ++-- internal/state/state_test.go | 2 +- internal/state/store.go | 2 +- internal/state/validation_test.go | 4 ++-- internal/statesync/reactor.go | 2 +- internal/store/store.go | 4 ++-- node/node_test.go | 2 +- rpc/jsonrpc/client/integration_test.go | 1 + tools/tools.go | 1 + types/validation.go | 10 +++++----- 18 files changed, 25 insertions(+), 17 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index e0f3fe163e0..14f384e22ce 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -33,7 +33,7 @@ linters: - staticcheck - structcheck - stylecheck - - typecheck + # - typecheck - unconvert # - unparam - unused diff --git a/crypto/secp256k1/secp256k1_nocgo.go b/crypto/secp256k1/secp256k1_nocgo.go index cba9bbe4c31..6b52dc5d28b 100644 --- a/crypto/secp256k1/secp256k1_nocgo.go +++ b/crypto/secp256k1/secp256k1_nocgo.go @@ -1,3 +1,4 @@ +//go:build !libsecp256k1 // +build !libsecp256k1 package secp256k1 diff --git a/internal/consensus/wal_fuzz.go b/internal/consensus/wal_fuzz.go index e15097c305c..06d894a812d 100644 --- a/internal/consensus/wal_fuzz.go +++ b/internal/consensus/wal_fuzz.go @@ -1,3 +1,4 @@ +//go:build gofuzz // +build gofuzz package consensus diff --git a/internal/libs/sync/deadlock.go b/internal/libs/sync/deadlock.go index 637d6fbb17e..21b5130ba42 100644 --- a/internal/libs/sync/deadlock.go +++ b/internal/libs/sync/deadlock.go @@ -1,3 +1,4 @@ +//go:build deadlock // +build deadlock package sync diff --git a/internal/libs/sync/sync.go b/internal/libs/sync/sync.go index a0880e7de98..c6e7101c606 100644 --- a/internal/libs/sync/sync.go +++ b/internal/libs/sync/sync.go @@ -1,3 +1,4 @@ +//go:build !deadlock // +build !deadlock package sync diff --git a/internal/mempool/ids.go b/internal/mempool/ids.go index 49a9ac60743..1bb03ceaf8f 100644 --- a/internal/mempool/ids.go +++ b/internal/mempool/ids.go @@ -7,7 +7,7 @@ import ( "github.com/tendermint/tendermint/types" ) -// nolint: golint +// nolint: revive // TODO: Rename type. type MempoolIDs struct { mtx tmsync.RWMutex diff --git a/internal/p2p/conn/conn_go110.go b/internal/p2p/conn/conn_go110.go index 68218810154..459c3169b14 100644 --- a/internal/p2p/conn/conn_go110.go +++ b/internal/p2p/conn/conn_go110.go @@ -1,3 +1,4 @@ +//go:build go1.10 // +build go1.10 package conn diff --git a/internal/p2p/conn/conn_notgo110.go b/internal/p2p/conn/conn_notgo110.go index ed642eb549a..21dffad2c23 100644 --- a/internal/p2p/conn/conn_notgo110.go +++ b/internal/p2p/conn/conn_notgo110.go @@ -1,3 +1,4 @@ +//go:build !go1.10 // +build !go1.10 package conn diff --git a/internal/state/state.go b/internal/state/state.go index ce9990cc252..6a1ea3c65bf 100644 --- a/internal/state/state.go +++ b/internal/state/state.go @@ -195,8 +195,8 @@ func (state *State) ToProto() (*tmstate.State, error) { return sm, nil } -// StateFromProto takes a state proto message & returns the local state type -func StateFromProto(pb *tmstate.State) (*State, error) { //nolint:golint +// FromProto takes a state proto message & returns the local state type +func FromProto(pb *tmstate.State) (*State, error) { //nolint:golint if pb == nil { return nil, errors.New("nil State") } diff --git a/internal/state/state_test.go b/internal/state/state_test.go index 36f7eae9d9d..fdf6812942d 100644 --- a/internal/state/state_test.go +++ b/internal/state/state_test.go @@ -1081,7 +1081,7 @@ func TestStateProto(t *testing.T) { assert.NoError(t, err, tt.testName) } - smt, err := sm.StateFromProto(pbs) + smt, err := sm.FromProto(pbs) if tt.expPass2 { require.NoError(t, err, tt.testName) require.Equal(t, tt.state, smt, tt.testName) diff --git a/internal/state/store.go b/internal/state/store.go index 787b5c8ad8c..aff165aa121 100644 --- a/internal/state/store.go +++ b/internal/state/store.go @@ -130,7 +130,7 @@ func (store dbStore) loadState(key []byte) (state State, err error) { %v\n`, err)) } - sm, err := StateFromProto(sp) + sm, err := FromProto(sp) if err != nil { return state, err } diff --git a/internal/state/validation_test.go b/internal/state/validation_test.go index 08c54f139dd..eb0cebbb737 100644 --- a/internal/state/validation_test.go +++ b/internal/state/validation_test.go @@ -270,7 +270,7 @@ func TestValidateBlockEvidence(t *testing.T) { A block with too much evidence fails */ evidence := make([]types.Evidence, 0) - var currentBytes int64 = 0 + var currentBytes int64 // more bytes than the maximum allowed for evidence for currentBytes <= maxBytesEvidence { newEv := types.NewMockDuplicateVoteEvidenceWithValidator(height, time.Now(), @@ -290,7 +290,7 @@ func TestValidateBlockEvidence(t *testing.T) { A good block with several pieces of good evidence passes */ evidence := make([]types.Evidence, 0) - var currentBytes int64 = 0 + var currentBytes int64 // precisely the amount of allowed evidence for { newEv := types.NewMockDuplicateVoteEvidenceWithValidator(height, defaultEvidenceTime, diff --git a/internal/statesync/reactor.go b/internal/statesync/reactor.go index 70b12b7fa4c..d0c656318ef 100644 --- a/internal/statesync/reactor.go +++ b/internal/statesync/reactor.go @@ -734,7 +734,7 @@ func (r *Reactor) handleLightBlockMessage(envelope p2p.Envelope) error { } case *ssproto.LightBlockResponse: - var height int64 = 0 + var height int64 if msg.LightBlock != nil { height = msg.LightBlock.SignedHeader.Header.Height } diff --git a/internal/store/store.go b/internal/store/store.go index 8848b76d973..c978241ff25 100644 --- a/internal/store/store.go +++ b/internal/store/store.go @@ -345,7 +345,7 @@ func (bs *BlockStore) pruneRange( var ( err error pruned uint64 - totalPruned uint64 = 0 + totalPruned uint64 ) batch := bs.db.NewBatch() @@ -392,7 +392,7 @@ func (bs *BlockStore) batchDelete( start, end []byte, preDeletionHook func(key, value []byte, batch dbm.Batch) error, ) (uint64, []byte, error) { - var pruned uint64 = 0 + var pruned uint64 iter, err := bs.db.Iterator(start, end) if err != nil { return pruned, start, err diff --git a/node/node_test.go b/node/node_test.go index 95f8d6dc230..c733555d408 100644 --- a/node/node_test.go +++ b/node/node_test.go @@ -257,7 +257,7 @@ func TestCreateProposalBlock(t *testing.T) { // fill the evidence pool with more evidence // than can fit in a block - var currentBytes int64 = 0 + var currentBytes int64 for currentBytes <= maxEvidenceBytes { ev := types.NewMockDuplicateVoteEvidenceWithValidator(height, time.Now(), privVals[0], "test-chain") currentBytes += int64(len(ev.Bytes())) diff --git a/rpc/jsonrpc/client/integration_test.go b/rpc/jsonrpc/client/integration_test.go index 228bbb460d6..26f24d2555a 100644 --- a/rpc/jsonrpc/client/integration_test.go +++ b/rpc/jsonrpc/client/integration_test.go @@ -1,3 +1,4 @@ +//go:build release // +build release // The code in here is comprehensive as an integration diff --git a/tools/tools.go b/tools/tools.go index 0e61333ec28..9fc291d99a3 100644 --- a/tools/tools.go +++ b/tools/tools.go @@ -1,3 +1,4 @@ +//go:build tools // +build tools // This file uses the recommended method for tracking developer tools in a go module. diff --git a/types/validation.go b/types/validation.go index 1bf0265db88..3b33e90db02 100644 --- a/types/validation.go +++ b/types/validation.go @@ -162,9 +162,9 @@ func verifyCommitBatch( var ( val *Validator valIdx int32 - seenVals = make(map[int32]int, len(commit.Signatures)) - batchSigIdxs = make([]int, 0, len(commit.Signatures)) - talliedVotingPower int64 = 0 + seenVals = make(map[int32]int, len(commit.Signatures)) + batchSigIdxs = make([]int, 0, len(commit.Signatures)) + talliedVotingPower int64 ) // attempt to create a batch verifier bv, ok := batch.CreateBatchVerifier(vals.GetProposer().PubKey) @@ -275,8 +275,8 @@ func verifyCommitSingle( var ( val *Validator valIdx int32 - seenVals = make(map[int32]int, len(commit.Signatures)) - talliedVotingPower int64 = 0 + seenVals = make(map[int32]int, len(commit.Signatures)) + talliedVotingPower int64 voteSignBytes []byte ) for idx, commitSig := range commit.Signatures {