diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c0eb3ca4d0c..93a76a5032c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -16,7 +16,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: - go-version: '^1.16' + go-version: '1.18' - uses: technote-space/get-diff-action@v6 with: PATTERNS: | @@ -26,7 +26,7 @@ jobs: - uses: golangci/golangci-lint-action@v3 with: # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. - version: v1.45 + version: v1.47.3 args: --timeout 10m github-token: ${{ secrets.github_token }} if: env.GIT_DIFF diff --git a/.golangci.yml b/.golangci.yml index c98f3c01f38..f85677e846d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -2,7 +2,7 @@ linters: enable: - asciicheck - bodyclose - - deadcode + # - deadcode - depguard - dogsled - dupl @@ -28,18 +28,22 @@ linters: # - maligned # - misspell - nakedret - - nolintlint + # - nolintlint - prealloc - staticcheck - - structcheck + # - structcheck // to be fixed by golangci-lint - stylecheck # - typecheck - unconvert # - unparam - - unused + # - unused - varcheck # - whitespace # - wsl + disable: + - unused + - deadcode + - nolintlint issues: exclude-rules: diff --git a/.vscode/settings.json b/.vscode/settings.json index 3a42e525f1e..2fdab835081 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,4 +5,5 @@ "--proto_path=${workspaceRoot}/third_party/proto" ] } + } diff --git a/abci/example/kvstore/kvstore_test.go b/abci/example/kvstore/kvstore_test.go index dafa8823785..93c1a1f25cf 100644 --- a/abci/example/kvstore/kvstore_test.go +++ b/abci/example/kvstore/kvstore_test.go @@ -162,7 +162,7 @@ func TestValUpdates(t *testing.T) { makeApplyBlock(t, kvstore, 2, diff, tx1, tx2, tx3) - vals1 = append(vals[:nInit-2], vals[nInit+1]) // nolint: gocritic + vals1 = append(vals[:nInit-2], vals[nInit+1]) //nolint: gocritic vals2 = kvstore.Validators() valsEqual(t, vals1, vals2) diff --git a/blockchain/msgs_test.go b/blockchain/msgs_test.go index df8efca1498..760d419d768 100644 --- a/blockchain/msgs_test.go +++ b/blockchain/msgs_test.go @@ -78,7 +78,7 @@ func TestBcStatusResponseMessageValidateBasic(t *testing.T) { } } -// nolint:lll // ignore line length in tests +//nolint:lll // ignore line length in tests func TestBlockchainMessageVectors(t *testing.T) { block := types.MakeBlock(int64(3), []types.Tx{types.Tx("Hello World")}, nil, nil) block.Version.Block = 11 // overwrite updated protocol version diff --git a/blockchain/v0/reactor.go b/blockchain/v0/reactor.go index c14d2d34a6a..b1b08e7897d 100644 --- a/blockchain/v0/reactor.go +++ b/blockchain/v0/reactor.go @@ -304,7 +304,7 @@ func (bcR *BlockchainReactor) poolRoutine(stateSynced bool) { case <-statusUpdateTicker.C: // ask for status updates - go bcR.BroadcastStatusRequest() // nolint: errcheck + go bcR.BroadcastStatusRequest() //nolint: errcheck } } diff --git a/blockchain/v2/reactor_test.go b/blockchain/v2/reactor_test.go index 9ee05aeaaa9..a135d68fd86 100644 --- a/blockchain/v2/reactor_test.go +++ b/blockchain/v2/reactor_test.go @@ -59,22 +59,18 @@ func (mp mockPeer) TrySend(byte, []byte) bool { return true } func (mp mockPeer) Set(string, interface{}) {} func (mp mockPeer) Get(string) interface{} { return struct{}{} } -// nolint:unused // ignore type mockBlockStore struct { blocks map[int64]*types.Block } -// nolint:unused // ignore func (ml *mockBlockStore) Height() int64 { return int64(len(ml.blocks)) } -// nolint:unused // ignore func (ml *mockBlockStore) LoadBlock(height int64) *types.Block { return ml.blocks[height] } -// nolint:unused // ignore func (ml *mockBlockStore) SaveBlock(block *types.Block, part *types.PartSet, commit *types.Commit) { ml.blocks[block.Height] = block } diff --git a/blockchain/v2/routine.go b/blockchain/v2/routine.go index dad0e737fa2..695e2b452db 100644 --- a/blockchain/v2/routine.go +++ b/blockchain/v2/routine.go @@ -52,7 +52,6 @@ func (rt *Routine) setLogger(logger log.Logger) { rt.logger = logger } -// nolint:unused func (rt *Routine) setMetrics(metrics *Metrics) { rt.metrics = metrics } diff --git a/cmd/tendermint/commands/debug/kill.go b/cmd/tendermint/commands/debug/kill.go index a2c7a5fe147..f79f432c750 100644 --- a/cmd/tendermint/commands/debug/kill.go +++ b/cmd/tendermint/commands/debug/kill.go @@ -105,7 +105,7 @@ func killProc(pid uint64, dir string) error { // pipe STDERR output from tailing the Tendermint process to a file // // NOTE: This will only work on UNIX systems. - cmd := exec.Command("tail", "-f", fmt.Sprintf("/proc/%d/fd/2", pid)) // nolint: gosec + cmd := exec.Command("tail", "-f", fmt.Sprintf("/proc/%d/fd/2", pid)) //nolint: gosec outFile, err := os.Create(filepath.Join(dir, "stacktrace.out")) if err != nil { diff --git a/cmd/tendermint/commands/debug/util.go b/cmd/tendermint/commands/debug/util.go index 226bfadc793..cb48ff5ac9b 100644 --- a/cmd/tendermint/commands/debug/util.go +++ b/cmd/tendermint/commands/debug/util.go @@ -67,7 +67,7 @@ func copyConfig(home, dir string) error { func dumpProfile(dir, addr, profile string, debug int) error { endpoint := fmt.Sprintf("%s/debug/pprof/%s?debug=%d", addr, profile, debug) - resp, err := http.Get(endpoint) // nolint: gosec + resp, err := http.Get(endpoint) //nolint: gosec if err != nil { return fmt.Errorf("failed to query for %s profile: %w", profile, err) } diff --git a/config/config_test.go b/config/config_test.go index 6a46933bcbc..03356c88bb6 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -140,8 +140,8 @@ func TestFastSyncConfigValidateBasic(t *testing.T) { assert.Error(t, cfg.ValidateBasic()) } +// nolint: lll func TestConsensusConfig_ValidateBasic(t *testing.T) { - // nolint: lll testcases := map[string]struct { modify func(*ConsensusConfig) expectErr bool @@ -166,6 +166,7 @@ func TestConsensusConfig_ValidateBasic(t *testing.T) { "PeerQueryMaj23SleepDuration negative": {func(c *ConsensusConfig) { c.PeerQueryMaj23SleepDuration = -1 }, true}, "DoubleSignCheckHeight negative": {func(c *ConsensusConfig) { c.DoubleSignCheckHeight = -1 }, true}, } + for desc, tc := range testcases { tc := tc // appease linter t.Run(desc, func(t *testing.T) { diff --git a/consensus/byzantine_test.go b/consensus/byzantine_test.go index 0dd5e43ca7d..9d0a4f39ff1 100644 --- a/consensus/byzantine_test.go +++ b/consensus/byzantine_test.go @@ -422,7 +422,7 @@ func TestByzantineConflictingProposalsWithPartition(t *testing.T) { // wait for someone in the big partition (B) to make a block <-blocksSubs[ind2].Out() - t.Log("A block has been committed. Healing partition") + t.Logf("A block has been committed. Healing partition") p2p.Connect2Switches(switches, ind0, ind1) p2p.Connect2Switches(switches, ind0, ind2) diff --git a/consensus/msgs_test.go b/consensus/msgs_test.go index b1f32e67dd4..296f6b12a11 100644 --- a/consensus/msgs_test.go +++ b/consensus/msgs_test.go @@ -314,7 +314,7 @@ func TestWALMsgProto(t *testing.T) { } } -// nolint:lll //ignore line length for tests +//nolint:lll //ignore line length for tests func TestConsMsgsVectors(t *testing.T) { date := time.Date(2018, 8, 30, 12, 0, 0, 0, time.UTC) psh := types.PartSetHeader{ diff --git a/consensus/reactor_test.go b/consensus/reactor_test.go index 3e7abc9acc0..cade58251dc 100644 --- a/consensus/reactor_test.go +++ b/consensus/reactor_test.go @@ -691,7 +691,7 @@ func capture() { // Ensure basic validation of structs is functioning func TestNewRoundStepMessageValidateBasic(t *testing.T) { - testCases := []struct { // nolint: maligned + testCases := []struct { expectErr bool messageRound int32 messageLastCommitRound int32 @@ -730,7 +730,7 @@ func TestNewRoundStepMessageValidateBasic(t *testing.T) { func TestNewRoundStepMessageValidateHeight(t *testing.T) { initialHeight := int64(10) - testCases := []struct { // nolint: maligned + testCases := []struct { //nolint: maligned expectErr bool messageLastCommitRound int32 messageHeight int64 @@ -880,7 +880,7 @@ func TestHasVoteMessageValidateBasic(t *testing.T) { invalidSignedMsgType tmproto.SignedMsgType = 0x03 ) - testCases := []struct { // nolint: maligned + testCases := []struct { //nolint: maligned expectErr bool messageRound int32 messageIndex int32 @@ -925,7 +925,7 @@ func TestVoteSetMaj23MessageValidateBasic(t *testing.T) { }, } - testCases := []struct { // nolint: maligned + testCases := []struct { //nolint: maligned expectErr bool messageRound int32 messageHeight int64 diff --git a/consensus/state.go b/consensus/state.go index b04e8d19266..eec541db52b 100644 --- a/consensus/state.go +++ b/consensus/state.go @@ -1955,7 +1955,7 @@ func (cs *State) tryAddVote(vote *types.Vote, peerID p2p.ID) (bool, error) { // If the vote height is off, we'll just ignore it, // But if it's a conflicting sig, add it to the cs.evpool. // If it's otherwise invalid, punish peer. - // nolint: gocritic + //nolint: gocritic if voteErr, ok := err.(*types.ErrVoteConflictingVotes); ok { if cs.privValidatorPubKey == nil { return false, errPubKeyIsNotSet diff --git a/crypto/armor/armor.go b/crypto/armor/armor.go index bfc2193e935..066d8822e1b 100644 --- a/crypto/armor/armor.go +++ b/crypto/armor/armor.go @@ -5,7 +5,7 @@ import ( "fmt" "io/ioutil" - "golang.org/x/crypto/openpgp/armor" // nolint: staticcheck + "golang.org/x/crypto/openpgp/armor" //nolint: staticcheck ) func EncodeArmor(blockType string, headers map[string]string, data []byte) string { diff --git a/crypto/merkle/proof_value.go b/crypto/merkle/proof_value.go index ab776216b03..842dc820182 100644 --- a/crypto/merkle/proof_value.go +++ b/crypto/merkle/proof_value.go @@ -85,8 +85,8 @@ func (op ValueOp) Run(args [][]byte) ([][]byte, error) { bz := new(bytes.Buffer) // Wrap to hash the KVPair. - encodeByteSlice(bz, op.key) // nolint: errcheck // does not error - encodeByteSlice(bz, vhash) // nolint: errcheck // does not error + encodeByteSlice(bz, op.key) //nolint: errcheck // does not error + encodeByteSlice(bz, vhash) //nolint: errcheck // does not error kvhash := leafHash(bz.Bytes()) if !bytes.Equal(kvhash, op.Proof.LeafHash) { diff --git a/crypto/secp256k1/secp256k1.go b/crypto/secp256k1/secp256k1.go index 8c943f623dc..21073bea120 100644 --- a/crypto/secp256k1/secp256k1.go +++ b/crypto/secp256k1/secp256k1.go @@ -9,7 +9,7 @@ import ( "math/big" secp256k1 "github.com/btcsuite/btcd/btcec" - "golang.org/x/crypto/ripemd160" // nolint: staticcheck // necessary for Bitcoin address format + "golang.org/x/crypto/ripemd160" //nolint: staticcheck // necessary for Bitcoin address format "github.com/tendermint/tendermint/crypto" tmjson "github.com/tendermint/tendermint/libs/json" diff --git a/evidence/reactor_test.go b/evidence/reactor_test.go index c0a22be26e8..d4772b00cf3 100644 --- a/evidence/reactor_test.go +++ b/evidence/reactor_test.go @@ -367,7 +367,7 @@ func exampleVote(t byte) *types.Vote { } } -// nolint:lll //ignore line length for tests +//nolint:lll //ignore line length for tests func TestEvidenceVectors(t *testing.T) { val := &types.Validator{ diff --git a/libs/clist/clist_test.go b/libs/clist/clist_test.go index ccb50ca8392..7b10478fd96 100644 --- a/libs/clist/clist_test.go +++ b/libs/clist/clist_test.go @@ -68,7 +68,7 @@ func TestSmall(t *testing.T) { // This test is quite hacky because it relies on SetFinalizer // which isn't guaranteed to run at all. -// + //nolint:unused,deadcode func _TestGCFifo(t *testing.T) { if runtime.GOARCH != "amd64" { diff --git a/libs/log/tmfmt_logger.go b/libs/log/tmfmt_logger.go index 391ae478a4b..492c1c12ea3 100644 --- a/libs/log/tmfmt_logger.go +++ b/libs/log/tmfmt_logger.go @@ -65,7 +65,7 @@ func (l tmfmtLogger) Log(keyvals ...interface{}) error { switch keyvals[i] { case kitlevel.Key(): excludeIndexes = append(excludeIndexes, i) - switch keyvals[i+1].(type) { // nolint:gocritic + switch keyvals[i+1].(type) { //nolint:gocritic case string: lvl = keyvals[i+1].(string) case kitlevel.Value: diff --git a/libs/pubsub/query/query.peg.go b/libs/pubsub/query/query.peg.go index a8e14c86983..98f8f4ed1e2 100644 --- a/libs/pubsub/query/query.peg.go +++ b/libs/pubsub/query/query.peg.go @@ -1,4 +1,4 @@ -// nolint +//nolint package query import ( diff --git a/libs/pubsub/subscription.go b/libs/pubsub/subscription.go index 4526df51e28..eca2c5dfb9d 100644 --- a/libs/pubsub/subscription.go +++ b/libs/pubsub/subscription.go @@ -43,7 +43,6 @@ func (s *Subscription) Out() <-chan Message { return s.out } -// nolint: misspell // Cancelled returns a channel that's closed when the subscription is // terminated and supposed to be used in a select statement. func (s *Subscription) Cancelled() <-chan struct{} { diff --git a/libs/rand/random.go b/libs/rand/random.go index 41d04a4406e..cb1a019c195 100644 --- a/libs/rand/random.go +++ b/libs/rand/random.go @@ -48,7 +48,7 @@ func (r *Rand) init() { } func (r *Rand) reset(seed int64) { - r.rand = mrand.New(mrand.NewSource(seed)) // nolint:gosec // G404: Use of weak random number generator + r.rand = mrand.New(mrand.NewSource(seed)) //nolint:gosec // G404: Use of weak random number generator } //---------------------------------------- diff --git a/light/provider/http/http.go b/light/provider/http/http.go index 665fcbe7079..f529cae484f 100644 --- a/light/provider/http/http.go +++ b/light/provider/http/http.go @@ -216,6 +216,6 @@ func validateHeight(height int64) (*int64, error) { // exponential backoff (with jitter) // 0.5s -> 2s -> 4.5s -> 8s -> 12.5 with 1s variation func backoffTimeout(attempt uint16) time.Duration { - // nolint:gosec // G404: Use of weak random number generator + //nolint:gosec // G404: Use of weak random number generator return time.Duration(500*attempt*attempt)*time.Millisecond + time.Duration(rand.Intn(1000))*time.Millisecond } diff --git a/light/proxy/routes.go b/light/proxy/routes.go index 2f53c88088b..7becbcc2f1f 100644 --- a/light/proxy/routes.go +++ b/light/proxy/routes.go @@ -62,7 +62,7 @@ func makeHealthFunc(c *lrpc.Client) rpcHealthFunc { type rpcStatusFunc func(ctx *rpctypes.Context) (*ctypes.ResultStatus, error) -// nolint: interfacer +//nolint: interfacer func makeStatusFunc(c *lrpc.Client) rpcStatusFunc { return func(ctx *rpctypes.Context) (*ctypes.ResultStatus, error) { return c.Status(ctx.Context()) @@ -278,7 +278,7 @@ func makeABCIInfoFunc(c *lrpc.Client) rpcABCIInfoFunc { type rpcBroadcastEvidenceFunc func(ctx *rpctypes.Context, ev types.Evidence) (*ctypes.ResultBroadcastEvidence, error) -// nolint: interfacer +//nolint: interfacer func makeBroadcastEvidenceFunc(c *lrpc.Client) rpcBroadcastEvidenceFunc { return func(ctx *rpctypes.Context, ev types.Evidence) (*ctypes.ResultBroadcastEvidence, error) { return c.BroadcastEvidence(ctx.Context(), ev) diff --git a/node/node.go b/node/node.go index d5042a55a1c..dd87d6bcddd 100644 --- a/node/node.go +++ b/node/node.go @@ -53,7 +53,7 @@ import ( tmtime "github.com/tendermint/tendermint/types/time" "github.com/tendermint/tendermint/version" - _ "net/http/pprof" // nolint: gosec // securely exposed on separate, optional port + _ "net/http/pprof" //nolint: gosec // securely exposed on separate, optional port _ "github.com/lib/pq" // provide the psql db driver ) diff --git a/p2p/conn/connection_test.go b/p2p/conn/connection_test.go index c41a46c48ee..f59df3dc8b0 100644 --- a/p2p/conn/connection_test.go +++ b/p2p/conn/connection_test.go @@ -51,7 +51,7 @@ func TestMConnectionSendFlushStop(t *testing.T) { clientConn := createTestMConnection(client) err := clientConn.Start() require.Nil(t, err) - defer clientConn.Stop() // nolint:errcheck // ignore for tests + defer clientConn.Stop() //nolint:errcheck // ignore for tests msg := []byte("abc") assert.True(t, clientConn.Send(0x01, msg)) @@ -89,7 +89,7 @@ func TestMConnectionSend(t *testing.T) { mconn := createTestMConnection(client) err := mconn.Start() require.Nil(t, err) - defer mconn.Stop() // nolint:errcheck // ignore for tests + defer mconn.Stop() //nolint:errcheck // ignore for tests msg := []byte("Ant-Man") assert.True(t, mconn.Send(0x01, msg)) @@ -128,12 +128,12 @@ func TestMConnectionReceive(t *testing.T) { mconn1 := createMConnectionWithCallbacks(client, onReceive, onError) err := mconn1.Start() require.Nil(t, err) - defer mconn1.Stop() // nolint:errcheck // ignore for tests + defer mconn1.Stop() //nolint:errcheck // ignore for tests mconn2 := createTestMConnection(server) err = mconn2.Start() require.Nil(t, err) - defer mconn2.Stop() // nolint:errcheck // ignore for tests + defer mconn2.Stop() //nolint:errcheck // ignore for tests msg := []byte("Cyclops") assert.True(t, mconn2.Send(0x01, msg)) @@ -156,7 +156,7 @@ func TestMConnectionStatus(t *testing.T) { mconn := createTestMConnection(client) err := mconn.Start() require.Nil(t, err) - defer mconn.Stop() // nolint:errcheck // ignore for tests + defer mconn.Stop() //nolint:errcheck // ignore for tests status := mconn.Status() assert.NotNil(t, status) @@ -179,7 +179,7 @@ func TestMConnectionPongTimeoutResultsInError(t *testing.T) { mconn := createMConnectionWithCallbacks(client, onReceive, onError) err := mconn.Start() require.Nil(t, err) - defer mconn.Stop() // nolint:errcheck // ignore for tests + defer mconn.Stop() //nolint:errcheck // ignore for tests serverGotPing := make(chan struct{}) go func() { @@ -218,7 +218,7 @@ func TestMConnectionMultiplePongsInTheBeginning(t *testing.T) { mconn := createMConnectionWithCallbacks(client, onReceive, onError) err := mconn.Start() require.Nil(t, err) - defer mconn.Stop() // nolint:errcheck // ignore for tests + defer mconn.Stop() //nolint:errcheck // ignore for tests // sending 3 pongs in a row (abuse) protoWriter := protoio.NewDelimitedWriter(server) @@ -273,7 +273,7 @@ func TestMConnectionMultiplePings(t *testing.T) { mconn := createMConnectionWithCallbacks(client, onReceive, onError) err := mconn.Start() require.Nil(t, err) - defer mconn.Stop() // nolint:errcheck // ignore for tests + defer mconn.Stop() //nolint:errcheck // ignore for tests // sending 3 pings in a row (abuse) // see https://github.com/tendermint/tendermint/issues/1190 @@ -322,7 +322,7 @@ func TestMConnectionPingPongs(t *testing.T) { mconn := createMConnectionWithCallbacks(client, onReceive, onError) err := mconn.Start() require.Nil(t, err) - defer mconn.Stop() // nolint:errcheck // ignore for tests + defer mconn.Stop() //nolint:errcheck // ignore for tests serverGotPing := make(chan struct{}) go func() { @@ -380,7 +380,7 @@ func TestMConnectionStopsAndReturnsError(t *testing.T) { mconn := createMConnectionWithCallbacks(client, onReceive, onError) err := mconn.Start() require.Nil(t, err) - defer mconn.Stop() // nolint:errcheck // ignore for tests + defer mconn.Stop() //nolint:errcheck // ignore for tests if err := client.Close(); err != nil { t.Error(err) @@ -492,8 +492,8 @@ func TestMConnectionReadErrorLongMessage(t *testing.T) { chOnRcv := make(chan struct{}) mconnClient, mconnServer := newClientAndServerConnsForReadErrors(t, chOnErr) - defer mconnClient.Stop() // nolint:errcheck // ignore for tests - defer mconnServer.Stop() // nolint:errcheck // ignore for tests + defer mconnClient.Stop() //nolint:errcheck // ignore for tests + defer mconnServer.Stop() //nolint:errcheck // ignore for tests mconnServer.onReceive = func(chID byte, msgBytes []byte) { chOnRcv <- struct{}{} @@ -528,8 +528,8 @@ func TestMConnectionReadErrorLongMessage(t *testing.T) { func TestMConnectionReadErrorUnknownMsgType(t *testing.T) { chOnErr := make(chan struct{}) mconnClient, mconnServer := newClientAndServerConnsForReadErrors(t, chOnErr) - defer mconnClient.Stop() // nolint:errcheck // ignore for tests - defer mconnServer.Stop() // nolint:errcheck // ignore for tests + defer mconnClient.Stop() //nolint:errcheck // ignore for tests + defer mconnServer.Stop() //nolint:errcheck // ignore for tests // send msg with unknown msg type _, err := protoio.NewDelimitedWriter(mconnClient.conn).WriteMsg(&types.Header{ChainID: "x"}) @@ -545,7 +545,7 @@ func TestMConnectionTrySend(t *testing.T) { mconn := createTestMConnection(client) err := mconn.Start() require.Nil(t, err) - defer mconn.Stop() // nolint:errcheck // ignore for tests + defer mconn.Stop() //nolint:errcheck // ignore for tests msg := []byte("Semicolon-Woman") resultCh := make(chan string, 2) @@ -564,7 +564,7 @@ func TestMConnectionTrySend(t *testing.T) { assert.Equal(t, "TrySend", <-resultCh) } -// nolint:lll //ignore line length for tests +//nolint:lll //ignore line length for tests func TestConnVectors(t *testing.T) { testCases := []struct { diff --git a/p2p/fuzz.go b/p2p/fuzz.go index 0ada85ecc05..e41e989bb9f 100644 --- a/p2p/fuzz.go +++ b/p2p/fuzz.go @@ -103,7 +103,7 @@ func (fc *FuzzedConnection) SetWriteDeadline(t time.Time) error { func (fc *FuzzedConnection) randomDuration() time.Duration { maxDelayMillis := int(fc.config.MaxDelay.Nanoseconds() / 1000) - return time.Millisecond * time.Duration(tmrand.Int()%maxDelayMillis) // nolint: gas + return time.Millisecond * time.Duration(tmrand.Int()%maxDelayMillis) //nolint: gas } // implements the fuzz (delay, kill conn) diff --git a/p2p/node_info_test.go b/p2p/node_info_test.go index 1bceb4a1017..9c317f8a168 100644 --- a/p2p/node_info_test.go +++ b/p2p/node_info_test.go @@ -33,7 +33,7 @@ func TestNodeInfoValidate(t *testing.T) { }{ { "Too Many Channels", - func(ni *DefaultNodeInfo) { ni.Channels = append(channels, byte(maxNumChannels)) }, // nolint: gocritic + func(ni *DefaultNodeInfo) { ni.Channels = append(channels, byte(maxNumChannels)) }, //nolint: gocritic true, }, {"Duplicate Channel", func(ni *DefaultNodeInfo) { ni.Channels = dupChannels }, true}, diff --git a/p2p/pex/pex_reactor_test.go b/p2p/pex/pex_reactor_test.go index 1e859e7becf..07e37cffa4a 100644 --- a/p2p/pex/pex_reactor_test.go +++ b/p2p/pex/pex_reactor_test.go @@ -215,7 +215,7 @@ func TestCheckSeeds(t *testing.T) { // 1. test creating peer with no seeds works peerSwitch := testCreateDefaultPeer(dir, 0) require.Nil(t, peerSwitch.Start()) - peerSwitch.Stop() // nolint:errcheck // ignore for tests + peerSwitch.Stop() //nolint:errcheck // ignore for tests // 2. create seed seed := testCreateSeed(dir, 1, []*p2p.NetAddress{}, []*p2p.NetAddress{}) @@ -223,7 +223,7 @@ func TestCheckSeeds(t *testing.T) { // 3. test create peer with online seed works peerSwitch = testCreatePeerWithSeed(dir, 2, seed) require.Nil(t, peerSwitch.Start()) - peerSwitch.Stop() // nolint:errcheck // ignore for tests + peerSwitch.Stop() //nolint:errcheck // ignore for tests // 4. test create peer with all seeds having unresolvable DNS fails badPeerConfig := &ReactorConfig{ @@ -232,7 +232,7 @@ func TestCheckSeeds(t *testing.T) { } peerSwitch = testCreatePeerWithConfig(dir, 2, badPeerConfig) require.Error(t, peerSwitch.Start()) - peerSwitch.Stop() // nolint:errcheck // ignore for tests + peerSwitch.Stop() //nolint:errcheck // ignore for tests // 5. test create peer with one good seed address succeeds badPeerConfig = &ReactorConfig{ @@ -242,7 +242,7 @@ func TestCheckSeeds(t *testing.T) { } peerSwitch = testCreatePeerWithConfig(dir, 2, badPeerConfig) require.Nil(t, peerSwitch.Start()) - peerSwitch.Stop() // nolint:errcheck // ignore for tests + peerSwitch.Stop() //nolint:errcheck // ignore for tests } func TestPEXReactorUsesSeedsIfNeeded(t *testing.T) { @@ -254,12 +254,12 @@ func TestPEXReactorUsesSeedsIfNeeded(t *testing.T) { // 1. create seed seed := testCreateSeed(dir, 0, []*p2p.NetAddress{}, []*p2p.NetAddress{}) require.Nil(t, seed.Start()) - defer seed.Stop() // nolint:errcheck // ignore for tests + defer seed.Stop() //nolint:errcheck // ignore for tests // 2. create usual peer with only seed configured. peer := testCreatePeerWithSeed(dir, 1, seed) require.Nil(t, peer.Start()) - defer peer.Stop() // nolint:errcheck // ignore for tests + defer peer.Stop() //nolint:errcheck // ignore for tests // 3. check that the peer connects to seed immediately assertPeersWithTimeout(t, []*p2p.Switch{peer}, 10*time.Millisecond, 3*time.Second, 1) @@ -274,18 +274,18 @@ func TestConnectionSpeedForPeerReceivedFromSeed(t *testing.T) { // 1. create peer peerSwitch := testCreateDefaultPeer(dir, 1) require.Nil(t, peerSwitch.Start()) - defer peerSwitch.Stop() // nolint:errcheck // ignore for tests + defer peerSwitch.Stop() //nolint:errcheck // ignore for tests // 2. Create seed which knows about the peer peerAddr := peerSwitch.NetAddress() seed := testCreateSeed(dir, 2, []*p2p.NetAddress{peerAddr}, []*p2p.NetAddress{peerAddr}) require.Nil(t, seed.Start()) - defer seed.Stop() // nolint:errcheck // ignore for tests + defer seed.Stop() //nolint:errcheck // ignore for tests // 3. create another peer with only seed configured. secondPeer := testCreatePeerWithSeed(dir, 3, seed) require.Nil(t, secondPeer.Start()) - defer secondPeer.Stop() // nolint:errcheck // ignore for tests + defer secondPeer.Stop() //nolint:errcheck // ignore for tests // 4. check that the second peer connects to seed immediately assertPeersWithTimeout(t, []*p2p.Switch{secondPeer}, 10*time.Millisecond, 3*time.Second, 1) @@ -308,13 +308,13 @@ func TestPEXReactorSeedMode(t *testing.T) { sw.SetAddrBook(book) err = sw.Start() require.NoError(t, err) - defer sw.Stop() // nolint:errcheck // ignore for tests + defer sw.Stop() //nolint:errcheck // ignore for tests assert.Zero(t, sw.Peers().Size()) peerSwitch := testCreateDefaultPeer(dir, 1) require.NoError(t, peerSwitch.Start()) - defer peerSwitch.Stop() // nolint:errcheck // ignore for tests + defer peerSwitch.Stop() //nolint:errcheck // ignore for tests // 1. Test crawlPeers dials the peer pexR.crawlPeers([]*p2p.NetAddress{peerSwitch.NetAddress()}) @@ -347,13 +347,13 @@ func TestPEXReactorDoesNotDisconnectFromPersistentPeerInSeedMode(t *testing.T) { sw.SetAddrBook(book) err = sw.Start() require.NoError(t, err) - defer sw.Stop() // nolint:errcheck // ignore for tests + defer sw.Stop() //nolint:errcheck // ignore for tests assert.Zero(t, sw.Peers().Size()) peerSwitch := testCreateDefaultPeer(dir, 1) require.NoError(t, peerSwitch.Start()) - defer peerSwitch.Stop() // nolint:errcheck // ignore for tests + defer peerSwitch.Stop() //nolint:errcheck // ignore for tests err = sw.AddPersistentPeers([]string{peerSwitch.NetAddress().String()}) require.NoError(t, err) @@ -619,7 +619,7 @@ func testCreateSeed(dir string, id int, knownAddrs, srcAddrs []*p2p.NetAddress) book := NewAddrBook(filepath.Join(dir, "addrbookSeed.json"), false) book.SetLogger(log.TestingLogger()) for j := 0; j < len(knownAddrs); j++ { - book.AddAddress(knownAddrs[j], srcAddrs[j]) // nolint:errcheck // ignore for tests + book.AddAddress(knownAddrs[j], srcAddrs[j]) //nolint:errcheck // ignore for tests book.MarkGood(knownAddrs[j].ID) } sw.SetAddrBook(book) diff --git a/p2p/transport_test.go b/p2p/transport_test.go index cfd927c9fdb..adaab399550 100644 --- a/p2p/transport_test.go +++ b/p2p/transport_test.go @@ -529,8 +529,8 @@ func TestTransportMultiplexRejectSelf(t *testing.T) { } _, err := mt.Accept(peerConfig{}) - if err, ok := err.(ErrRejected); ok { - if !err.IsSelf() { + if e, ok := err.(ErrRejected); ok { + if !e.IsSelf() { t.Errorf("expected to reject self, got: %v", err) } } else { diff --git a/p2p/upnp/upnp.go b/p2p/upnp/upnp.go index c00530acae6..5a92e399532 100644 --- a/p2p/upnp/upnp.go +++ b/p2p/upnp/upnp.go @@ -202,7 +202,7 @@ func localIPv4() (net.IP, error) { } func getServiceURL(rootURL string) (url, urnDomain string, err error) { - r, err := http.Get(rootURL) // nolint: gosec + r, err := http.Get(rootURL) //nolint: gosec if err != nil { return } diff --git a/privval/msgs_test.go b/privval/msgs_test.go index bf532bd7b99..afefa0e77c8 100644 --- a/privval/msgs_test.go +++ b/privval/msgs_test.go @@ -57,7 +57,7 @@ func exampleProposal() *types.Proposal { } } -// nolint:lll // ignore line length for tests +//nolint:lll // ignore line length for tests func TestPrivvalVectors(t *testing.T) { pk := ed25519.GenPrivKeyFromSecret([]byte("it's a secret")).PubKey() ppk, err := cryptoenc.PubKeyToProto(pk) diff --git a/proxy/multi_app_conn_test.go b/proxy/multi_app_conn_test.go index 34b0d0830e8..a7e77148e1a 100644 --- a/proxy/multi_app_conn_test.go +++ b/proxy/multi_app_conn_test.go @@ -53,7 +53,7 @@ func TestAppConns_Failure(t *testing.T) { }() quitCh := make(chan struct{}) - var recvQuitCh <-chan struct{} // nolint:gosimple + var recvQuitCh <-chan struct{} //nolint:gosimple recvQuitCh = quitCh clientCreatorMock := &mocks.ClientCreator{} diff --git a/rpc/jsonrpc/client/ws_client.go b/rpc/jsonrpc/client/ws_client.go index 44bf5f0987f..09b41888fc7 100644 --- a/rpc/jsonrpc/client/ws_client.go +++ b/rpc/jsonrpc/client/ws_client.go @@ -30,7 +30,7 @@ const ( // the remote server. // // WSClient is safe for concurrent use by multiple goroutines. -type WSClient struct { // nolint: maligned +type WSClient struct { //nolint: maligned conn *websocket.Conn Address string // IP:PORT or /path/to/socket @@ -265,7 +265,7 @@ func (c *WSClient) dial() error { Proxy: http.ProxyFromEnvironment, } rHeader := http.Header{} - conn, _, err := dialer.Dial(c.protocol+"://"+c.Address+c.Endpoint, rHeader) // nolint:bodyclose + conn, _, err := dialer.Dial(c.protocol+"://"+c.Address+c.Endpoint, rHeader) //nolint:bodyclose if err != nil { return err } diff --git a/rpc/jsonrpc/client/ws_client_test.go b/rpc/jsonrpc/client/ws_client_test.go index 2e6403806c8..b4ac8f83b94 100644 --- a/rpc/jsonrpc/client/ws_client_test.go +++ b/rpc/jsonrpc/client/ws_client_test.go @@ -72,7 +72,7 @@ func TestWSClientReconnectsAfterReadFailure(t *testing.T) { defer s.Close() c := startClient(t, "//"+s.Listener.Addr().String()) - defer c.Stop() // nolint:errcheck // ignore for tests + defer c.Stop() //nolint:errcheck // ignore for tests wg.Add(1) go callWgDoneOnResult(t, c, &wg) @@ -104,7 +104,7 @@ func TestWSClientReconnectsAfterWriteFailure(t *testing.T) { s := httptest.NewServer(h) c := startClient(t, "//"+s.Listener.Addr().String()) - defer c.Stop() // nolint:errcheck // ignore for tests + defer c.Stop() //nolint:errcheck // ignore for tests wg.Add(2) go callWgDoneOnResult(t, c, &wg) @@ -132,7 +132,7 @@ func TestWSClientReconnectFailure(t *testing.T) { s := httptest.NewServer(h) c := startClient(t, "//"+s.Listener.Addr().String()) - defer c.Stop() // nolint:errcheck // ignore for tests + defer c.Stop() //nolint:errcheck // ignore for tests go func() { for { @@ -181,7 +181,7 @@ func TestNotBlockingOnStop(t *testing.T) { timeout := 2 * time.Second s := httptest.NewServer(&myHandler{}) c := startClient(t, "//"+s.Listener.Addr().String()) - c.Call(context.Background(), "a", make(map[string]interface{})) // nolint:errcheck // ignore for tests + c.Call(context.Background(), "a", make(map[string]interface{})) //nolint:errcheck // ignore for tests // Let the readRoutine get around to blocking time.Sleep(time.Second) passCh := make(chan struct{}) diff --git a/rpc/jsonrpc/server/http_json_handler.go b/rpc/jsonrpc/server/http_json_handler.go index 8724ab8e47f..f8b4656b31c 100644 --- a/rpc/jsonrpc/server/http_json_handler.go +++ b/rpc/jsonrpc/server/http_json_handler.go @@ -238,5 +238,5 @@ func writeListOfEndpoints(w http.ResponseWriter, r *http.Request, funcMap map[st buf.WriteString("") w.Header().Set("Content-Type", "text/html") w.WriteHeader(200) - w.Write(buf.Bytes()) // nolint: errcheck + w.Write(buf.Bytes()) //nolint: errcheck } diff --git a/statesync/snapshots.go b/statesync/snapshots.go index e4936c91a24..917c0494754 100644 --- a/statesync/snapshots.go +++ b/statesync/snapshots.go @@ -132,7 +132,7 @@ func (p *snapshotPool) GetPeer(snapshot *snapshot) p2p.Peer { if len(peers) == 0 { return nil } - return peers[rand.Intn(len(peers))] // nolint:gosec // G404: Use of weak random number generator + return peers[rand.Intn(len(peers))] //nolint:gosec // G404: Use of weak random number generator } // GetPeers returns the peers for a snapshot. diff --git a/test/e2e/app/snapshots.go b/test/e2e/app/snapshots.go index 4ef20375ff8..9fd6ba41916 100644 --- a/test/e2e/app/snapshots.go +++ b/test/e2e/app/snapshots.go @@ -72,7 +72,7 @@ func (s *SnapshotStore) saveMetadata() error { // save the file to a new file and move it to make saving atomic. newFile := filepath.Join(s.dir, "metadata.json.new") file := filepath.Join(s.dir, "metadata.json") - err = ioutil.WriteFile(newFile, bz, 0644) // nolint: gosec + err = ioutil.WriteFile(newFile, bz, 0644) //nolint: gosec if err != nil { return err } diff --git a/test/e2e/runner/setup.go b/test/e2e/runner/setup.go index 919e4542fce..fe52fe1a525 100644 --- a/test/e2e/runner/setup.go +++ b/test/e2e/runner/setup.go @@ -1,4 +1,4 @@ -// nolint: gosec +//nolint: gosec package main import ( diff --git a/test/fuzz/p2p/addrbook/fuzz.go b/test/fuzz/p2p/addrbook/fuzz.go index f2799ef04dc..a1845a7db44 100644 --- a/test/fuzz/p2p/addrbook/fuzz.go +++ b/test/fuzz/p2p/addrbook/fuzz.go @@ -1,4 +1,4 @@ -// nolint: gosec +//nolint: gosec package addr import ( diff --git a/test/fuzz/p2p/addrbook/init-corpus/main.go b/test/fuzz/p2p/addrbook/init-corpus/main.go index d5cc3a9a914..92fcaf46905 100644 --- a/test/fuzz/p2p/addrbook/init-corpus/main.go +++ b/test/fuzz/p2p/addrbook/init-corpus/main.go @@ -1,4 +1,4 @@ -// nolint: gosec +//nolint: gosec package main import ( diff --git a/test/fuzz/p2p/pex/init-corpus/main.go b/test/fuzz/p2p/pex/init-corpus/main.go index 2fe09c0dceb..f9f8e948273 100644 --- a/test/fuzz/p2p/pex/init-corpus/main.go +++ b/test/fuzz/p2p/pex/init-corpus/main.go @@ -1,4 +1,4 @@ -// nolint: gosec +//nolint: gosec package main import ( diff --git a/test/fuzz/p2p/secret_connection/init-corpus/main.go b/test/fuzz/p2p/secret_connection/init-corpus/main.go index 635f2d99f9b..0755b3b50cd 100644 --- a/test/fuzz/p2p/secret_connection/init-corpus/main.go +++ b/test/fuzz/p2p/secret_connection/init-corpus/main.go @@ -1,4 +1,4 @@ -// nolint: gosec +//nolint: gosec package main import ( diff --git a/test/maverick/consensus/state.go b/test/maverick/consensus/state.go index 84c2ffcb035..59eacb19d2e 100644 --- a/test/maverick/consensus/state.go +++ b/test/maverick/consensus/state.go @@ -1779,7 +1779,7 @@ func (cs *State) tryAddVote(vote *types.Vote, peerID p2p.ID) (bool, error) { // If the vote height is off, we'll just ignore it, // But if it's a conflicting sig, add it to the cs.evpool. // If it's otherwise invalid, punish peer. - // nolint: gocritic + //nolint: gocritic if voteErr, ok := err.(*types.ErrVoteConflictingVotes); ok { if cs.privValidatorPubKey == nil { return false, errPubKeyIsNotSet diff --git a/test/maverick/node/node.go b/test/maverick/node/node.go index 822967158b7..a5ae7a18450 100644 --- a/test/maverick/node/node.go +++ b/test/maverick/node/node.go @@ -7,7 +7,7 @@ import ( "fmt" "net" "net/http" - _ "net/http/pprof" // nolint: gosec // securely exposed on separate, optional port + _ "net/http/pprof" //nolint: gosec // securely exposed on separate, optional port "strconv" "strings" "time" diff --git a/types/event_bus.go b/types/event_bus.go index 2506efa83b3..af5b2df05b8 100644 --- a/types/event_bus.go +++ b/types/event_bus.go @@ -23,7 +23,7 @@ type EventBusSubscriber interface { type Subscription interface { Out() <-chan tmpubsub.Message - Cancelled() <-chan struct{} // nolint: misspell + Cancelled() <-chan struct{} //nolint: misspell Err() error } diff --git a/types/validator_set_test.go b/types/validator_set_test.go index 6fbbb088576..d9283001cc9 100644 --- a/types/validator_set_test.go +++ b/types/validator_set_test.go @@ -1663,8 +1663,6 @@ func (valz validatorsByPriority) Swap(i, j int) { valz[i], valz[j] = valz[j], valz[i] } -//------------------------------------- - type testValsByVotingPower []testVal func (tvals testValsByVotingPower) Len() int {