Skip to content

Commit

Permalink
Bump linter to 1.47 (tendermint#9218)
Browse files Browse the repository at this point in the history
*bump linter to 1.47

Co-authored-by: William Banfield <[email protected]>
  • Loading branch information
samricotta and williambanfield authored Aug 11, 2022
1 parent fbd754b commit dad439f
Show file tree
Hide file tree
Showing 49 changed files with 92 additions and 94 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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
12 changes: 8 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ linters:
enable:
- asciicheck
- bodyclose
- deadcode
# - deadcode
- depguard
- dogsled
- dupl
Expand All @@ -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:
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
"--proto_path=${workspaceRoot}/third_party/proto"
]
}

}
2 changes: 1 addition & 1 deletion abci/example/kvstore/kvstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion blockchain/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion blockchain/v0/reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

}
}
Expand Down
4 changes: 0 additions & 4 deletions blockchain/v2/reactor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
1 change: 0 additions & 1 deletion blockchain/v2/routine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/tendermint/commands/debug/kill.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion cmd/tendermint/commands/debug/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
3 changes: 2 additions & 1 deletion config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion consensus/byzantine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion consensus/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
8 changes: 4 additions & 4 deletions consensus/reactor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -925,7 +925,7 @@ func TestVoteSetMaj23MessageValidateBasic(t *testing.T) {
},
}

testCases := []struct { // nolint: maligned
testCases := []struct { //nolint: maligned
expectErr bool
messageRound int32
messageHeight int64
Expand Down
2 changes: 1 addition & 1 deletion consensus/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion crypto/armor/armor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions crypto/merkle/proof_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ func (op ValueOp) Run(args [][]byte) ([][]byte, error) {

bz := new(bytes.Buffer)
// Wrap <op.Key, vhash> 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) {
Expand Down
2 changes: 1 addition & 1 deletion crypto/secp256k1/secp256k1.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion evidence/reactor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion libs/clist/clist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
2 changes: 1 addition & 1 deletion libs/log/tmfmt_logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion libs/pubsub/query/query.peg.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// nolint
//nolint
package query

import (
Expand Down
1 change: 0 additions & 1 deletion libs/pubsub/subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{} {
Expand Down
2 changes: 1 addition & 1 deletion libs/rand/random.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

//----------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion light/provider/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
4 changes: 2 additions & 2 deletions light/proxy/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
Loading

0 comments on commit dad439f

Please sign in to comment.