Bump linter to 1.47 (#9218)

*bump linter to 1.47

Co-authored-by: William Banfield <4561443+williambanfield@users.noreply.github.com>
This commit is contained in:
samricotta
2022-08-11 15:53:17 +02:00
committed by GitHub
parent fbd754b4de
commit dad439f115
49 changed files with 92 additions and 94 deletions

View File

@@ -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

View File

@@ -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:

View File

@@ -5,4 +5,5 @@
"--proto_path=${workspaceRoot}/third_party/proto"
]
}
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -140,8 +140,8 @@ func TestFastSyncConfigValidateBasic(t *testing.T) {
assert.Error(t, cfg.ValidateBasic())
}
func TestConsensusConfig_ValidateBasic(t *testing.T) {
// nolint: lll
func TestConsensusConfig_ValidateBasic(t *testing.T) {
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) {

View File

@@ -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)

View File

@@ -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

View File

@@ -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" {

View File

@@ -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{} {

View File

@@ -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 {

View File

@@ -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 {