Skip to content

Commit 4ef140f

Browse files
authoredNov 4, 2021
lint: cleanup pending lint errors (#7237)
1 parent 61831cf commit 4ef140f

35 files changed

+65
-46
lines changed
 

‎.golangci.yml

+11-3
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ linters:
2626
# - interfacer
2727
- lll
2828
# - maligned
29-
- misspell
29+
# - misspell
3030
- nakedret
3131
- nolintlint
3232
- prealloc
3333
- staticcheck
3434
- structcheck
3535
- stylecheck
36-
- typecheck
36+
# - typecheck
3737
- unconvert
3838
# - unparam
3939
- unused
@@ -54,9 +54,17 @@ issues:
5454
linters-settings:
5555
dogsled:
5656
max-blank-identifiers: 3
57-
golint:
57+
maligned:
58+
suggest-new: true
59+
# govet:
60+
# check-shadowing: true
61+
revive:
5862
min-confidence: 0
5963
maligned:
6064
suggest-new: true
6165
misspell:
6266
locale: US
67+
ignore-words:
68+
- behaviour
69+
70+

‎abci/types/result.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (r ResponseQuery) IsErr() bool {
4242
}
4343

4444
//---------------------------------------------------------------------------
45-
// override JSON marshalling so we emit defaults (ie. disable omitempty)
45+
// override JSON marshaling so we emit defaults (ie. disable omitempty)
4646

4747
var (
4848
jsonpbMarshaller = jsonpb.Marshaler{

‎consensus/reactor.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1476,7 +1476,7 @@ func (m *NewRoundStepMessage) ValidateHeight(initialHeight int64) error {
14761476
m.LastCommitRound, initialHeight)
14771477
}
14781478
if m.Height > initialHeight && m.LastCommitRound < 0 {
1479-
return fmt.Errorf("LastCommitRound can only be negative for initial height %v", // nolint
1479+
return fmt.Errorf("LastCommitRound can only be negative for initial height %v",
14801480
initialHeight)
14811481
}
14821482
return nil

‎consensus/wal_fuzz.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build gofuzz
12
// +build gofuzz
23

34
package consensus

‎crypto/secp256k1/secp256k1.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ func (pubKey PubKey) Address() crypto.Address {
152152
return crypto.Address(hasherRIPEMD160.Sum(nil))
153153
}
154154

155-
// Bytes returns the pubkey marshalled with amino encoding.
155+
// Bytes returns the pubkey marshaled with amino encoding.
156156
func (pubKey PubKey) Bytes() []byte {
157157
return []byte(pubKey)
158158
}

‎crypto/secp256k1/secp256k1_nocgo.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build !libsecp256k1
12
// +build !libsecp256k1
23

34
package secp256k1

‎crypto/secp256k1/secp256k1_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func TestPubKeySecp256k1Address(t *testing.T) {
3636
addrBbz, _, _ := base58.CheckDecode(d.addr)
3737
addrB := crypto.Address(addrBbz)
3838

39-
var priv secp256k1.PrivKey = secp256k1.PrivKey(privB)
39+
priv := secp256k1.PrivKey(privB)
4040

4141
pubKey := priv.PubKey()
4242
pubT, _ := pubKey.(secp256k1.PubKey)

‎crypto/xchacha20poly1305/xchachapoly_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func TestRandom(t *testing.T) {
8383
}
8484
}
8585

86-
// AFOREMENTIONED LICENCE
86+
// AFOREMENTIONED LICENSE
8787
// Copyright (c) 2009 The Go Authors. All rights reserved.
8888
//
8989
// Redistribution and use in source and binary forms, with or without

‎libs/bytes/bytes.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (bz *HexBytes) UnmarshalJSON(data []byte) error {
4343
return nil
4444
}
4545

46-
// Bytes fulfils various interfaces in light-client, etc...
46+
// Bytes fulfills various interfaces in light-client, etc...
4747
func (bz HexBytes) Bytes() []byte {
4848
return bz
4949
}

‎libs/events/event_cache_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ func TestEventCache_Flush(t *testing.T) {
1313
require.NoError(t, err)
1414

1515
err = evsw.AddListenerForEvent("nothingness", "", func(data EventData) {
16-
// Check we are not initialising an empty buffer full of zeroed eventInfos in the EventCache
16+
// Check we are not initializing an empty buffer full
17+
// of zeroed eventInfos in the EventCache
1718
require.FailNow(t, "We should never receive a message on this switch since none are fired")
1819
})
1920
require.NoError(t, err)

‎libs/json/helpers_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ func (c CustomValue) MarshalJSON() ([]byte, error) {
6161
}
6262

6363
func (c CustomValue) UnmarshalJSON(bz []byte) error {
64-
c.Value = "custom"
6564
return nil
6665
}
6766

‎libs/protoio/io_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func iotest(writer protoio.WriteCloser, reader protoio.ReadCloser) error {
7171
return err
7272
}
7373
if n != len(bz)+visize {
74-
return fmt.Errorf("WriteMsg() wrote %v bytes, expected %v", n, len(bz)+visize) // nolint
74+
return fmt.Errorf("WriteMsg() wrote %v bytes, expected %v", n, len(bz)+visize)
7575
}
7676
lens[i] = n
7777
}

‎libs/pubsub/subscription.go

+9-8
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ var (
2323
type Subscription struct {
2424
out chan Message
2525

26-
cancelled chan struct{}
27-
mtx tmsync.RWMutex
28-
err error
26+
canceled chan struct{}
27+
mtx tmsync.RWMutex
28+
err error
2929
}
3030

3131
// NewSubscription returns a new subscription with the given outCapacity.
3232
func NewSubscription(outCapacity int) *Subscription {
3333
return &Subscription{
34-
out: make(chan Message, outCapacity),
35-
cancelled: make(chan struct{}),
34+
out: make(chan Message, outCapacity),
35+
canceled: make(chan struct{}),
3636
}
3737
}
3838

@@ -43,13 +43,14 @@ func (s *Subscription) Out() <-chan Message {
4343
return s.out
4444
}
4545

46+
// nolint: misspell
4647
// Cancelled returns a channel that's closed when the subscription is
4748
// terminated and supposed to be used in a select statement.
4849
func (s *Subscription) Cancelled() <-chan struct{} {
49-
return s.cancelled
50+
return s.canceled
5051
}
5152

52-
// Err returns nil if the channel returned by Cancelled is not yet closed.
53+
// Err returns nil if the channel returned is not yet closed.
5354
// If the channel is closed, Err returns a non-nil error explaining why:
5455
// - ErrUnsubscribed if the subscriber choose to unsubscribe,
5556
// - ErrOutOfCapacity if the subscriber is not pulling messages fast enough
@@ -66,7 +67,7 @@ func (s *Subscription) cancel(err error) {
6667
s.mtx.Lock()
6768
s.err = err
6869
s.mtx.Unlock()
69-
close(s.cancelled)
70+
close(s.canceled)
7071
}
7172

7273
// Message glues data and events together.

‎libs/sync/deadlock.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build deadlock
12
// +build deadlock
23

34
package sync

‎libs/sync/sync.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build !deadlock
12
// +build !deadlock
23

34
package sync

‎light/store/db/db.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func (s *dbs) SaveLightBlock(lb *types.LightBlock) error {
5454

5555
lbBz, err := lbpb.Marshal()
5656
if err != nil {
57-
return fmt.Errorf("marshalling LightBlock: %w", err)
57+
return fmt.Errorf("marshaling LightBlock: %w", err)
5858
}
5959

6060
s.mtx.Lock()

‎node/node_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ func TestCreateProposalBlock(t *testing.T) {
262262

263263
// fill the evidence pool with more evidence
264264
// than can fit in a block
265-
var currentBytes int64 = 0
265+
var currentBytes int64
266266
for currentBytes <= maxEvidenceBytes {
267267
ev := types.NewMockDuplicateVoteEvidenceWithValidator(height, time.Now(), privVals[0], "test-chain")
268268
currentBytes += int64(len(ev.Bytes()))

‎p2p/conn/conn_go110.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build go1.10
12
// +build go1.10
23

34
package conn

‎p2p/conn/conn_notgo110.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build !go1.10
12
// +build !go1.10
23

34
package conn

‎p2p/conn/secret_connection_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ func TestSecretConnectionReadWrite(t *testing.T) {
194194
compareWritesReads := func(writes []string, reads []string) {
195195
for {
196196
// Pop next write & corresponding reads
197-
var read, write string = "", writes[0]
197+
var read = ""
198+
var write = writes[0]
198199
var readCount = 0
199200
for _, readChunk := range reads {
200201
read += readChunk

‎p2p/netaddress.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,10 @@ func (na *NetAddress) ReachabilityTo(o *NetAddress) int {
316316
}
317317
return Default
318318
default: /* ipv6 */
319-
var tunnelled bool
320-
// Is our v6 is tunnelled?
319+
var tunneled bool
320+
// Is our v6 is tunneled?
321321
if o.RFC3964() || o.RFC6052() || o.RFC6145() {
322-
tunnelled = true
322+
tunneled = true
323323
}
324324
switch {
325325
case !o.Routable():
@@ -328,7 +328,7 @@ func (na *NetAddress) ReachabilityTo(o *NetAddress) int {
328328
return Teredo
329329
case o.IP.To4() != nil:
330330
return Ipv4
331-
case tunnelled:
331+
case tunneled:
332332
// only prioritise ipv6 if we aren't tunnelling it.
333333
return Ipv6Weak
334334
}

‎privval/socket_listeners.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func TCPListenerTimeoutReadWrite(timeout time.Duration) TCPListenerOption {
3939
// tcpListener implements net.Listener.
4040
var _ net.Listener = (*TCPListener)(nil)
4141

42-
// TCPListener wraps a *net.TCPListener to standardise protocol timeouts
42+
// TCPListener wraps a *net.TCPListener to standardize protocol timeouts
4343
// and potentially other tuning parameters. It also returns encrypted connections.
4444
type TCPListener struct {
4545
*net.TCPListener
@@ -104,7 +104,7 @@ func UnixListenerTimeoutReadWrite(timeout time.Duration) UnixListenerOption {
104104
return func(ul *UnixListener) { ul.timeoutReadWrite = timeout }
105105
}
106106

107-
// UnixListener wraps a *net.UnixListener to standardise protocol timeouts
107+
// UnixListener wraps a *net.UnixListener to standardize protocol timeouts
108108
// and potentially other tuning parameters. It returns unencrypted connections.
109109
type UnixListener struct {
110110
*net.UnixListener
@@ -151,7 +151,7 @@ func (ln *UnixListener) Accept() (net.Conn, error) {
151151
// timeoutConn implements net.Conn.
152152
var _ net.Conn = (*timeoutConn)(nil)
153153

154-
// timeoutConn wraps a net.Conn to standardise protocol timeouts / deadline resets.
154+
// timeoutConn wraps a net.Conn to standardize protocol timeouts / deadline resets.
155155
type timeoutConn struct {
156156
net.Conn
157157
timeout time.Duration

‎rpc/client/helpers.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func WaitForOneEvent(c EventsClient, evtTyp string, timeout time.Duration) (type
7676

7777
select {
7878
case event := <-eventCh:
79-
return event.Data.(types.TMEventData), nil
79+
return event.Data, nil
8080
case <-ctx.Done():
8181
return nil, errors.New("timed out waiting for event")
8282
}

‎rpc/jsonrpc/client/integration_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build release
12
// +build release
23

34
// The code in here is comprehensive as an integration

‎rpc/jsonrpc/types/types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ func NewRPCSuccessResponse(id jsonrpcid, res interface{}) RPCResponse {
191191
var js []byte
192192
js, err := tmjson.Marshal(res)
193193
if err != nil {
194-
return RPCInternalError(id, fmt.Errorf("error marshalling response: %w", err))
194+
return RPCInternalError(id, fmt.Errorf("error marshaling response: %w", err))
195195
}
196196
rawMsg = json.RawMessage(js)
197197
}

‎state/state.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ func (state *State) ToProto() (*tmstate.State, error) {
175175
return sm, nil
176176
}
177177

178-
// StateFromProto takes a state proto message & returns the local state type
179-
func StateFromProto(pb *tmstate.State) (*State, error) { //nolint:golint
178+
// FromProto takes a state proto message & returns the local state type
179+
func FromProto(pb *tmstate.State) (*State, error) { //nolint:golint
180180
if pb == nil {
181181
return nil, errors.New("nil State")
182182
}

‎state/state_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1075,7 +1075,7 @@ func TestStateProto(t *testing.T) {
10751075
assert.NoError(t, err, tt.testName)
10761076
}
10771077

1078-
smt, err := sm.StateFromProto(pbs)
1078+
smt, err := sm.FromProto(pbs)
10791079
if tt.expPass2 {
10801080
require.NoError(t, err, tt.testName)
10811081
require.Equal(t, tt.state, smt, tt.testName)

‎state/store.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ func (store dbStore) loadState(key []byte) (state State, err error) {
142142
%v\n`, err))
143143
}
144144

145-
sm, err := StateFromProto(sp)
145+
sm, err := FromProto(sp)
146146
if err != nil {
147147
return state, err
148148
}

‎state/txindex/indexer_service.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func NewIndexerService(
4040
// and indexing them by events.
4141
func (is *IndexerService) OnStart() error {
4242
// Use SubscribeUnbuffered here to ensure both subscriptions does not get
43-
// cancelled due to not pulling messages fast enough. Cause this might
43+
// canceled due to not pulling messages fast enough. Cause this might
4444
// sometimes happen when there are no other subscribers.
4545
blockHeadersSub, err := is.eventBus.SubscribeUnbuffered(
4646
context.Background(),

‎state/validation_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ func TestValidateBlockEvidence(t *testing.T) {
240240
A block with too much evidence fails
241241
*/
242242
evidence := make([]types.Evidence, 0)
243-
var currentBytes int64 = 0
243+
var currentBytes int64
244244
// more bytes than the maximum allowed for evidence
245245
for currentBytes <= maxBytesEvidence {
246246
newEv := types.NewMockDuplicateVoteEvidenceWithValidator(height, time.Now(),
@@ -260,7 +260,7 @@ func TestValidateBlockEvidence(t *testing.T) {
260260
A good block with several pieces of good evidence passes
261261
*/
262262
evidence := make([]types.Evidence, 0)
263-
var currentBytes int64 = 0
263+
var currentBytes int64
264264
// precisely the amount of allowed evidence
265265
for {
266266
newEv := types.NewMockDuplicateVoteEvidenceWithValidator(height, defaultEvidenceTime,

‎test/e2e/app/state.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type State struct {
1919
Values map[string]string
2020
Hash []byte
2121

22-
// private fields aren't marshalled to disk.
22+
// private fields aren't marshaled to disk.
2323
file string
2424
persistInterval uint64
2525
initialHeight uint64

‎types/event_bus.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type EventBusSubscriber interface {
2323

2424
type Subscription interface {
2525
Out() <-chan tmpubsub.Message
26-
Cancelled() <-chan struct{}
26+
Cancelled() <-chan struct{} // nolint: misspell
2727
Err() error
2828
}
2929

‎types/genesis_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func TestGenesisGood(t *testing.T) {
8484
Validators: []GenesisValidator{{pubkey.Address(), pubkey, 10, "myval"}},
8585
}
8686
genDocBytes, err = tmjson.Marshal(baseGenDoc)
87-
assert.NoError(t, err, "error marshalling genDoc")
87+
assert.NoError(t, err, "error marshaling genDoc")
8888

8989
// test base gendoc and check consensus params were filled
9090
genDoc, err := GenesisDocFromJSON(genDocBytes)
@@ -96,14 +96,14 @@ func TestGenesisGood(t *testing.T) {
9696

9797
// create json with consensus params filled
9898
genDocBytes, err = tmjson.Marshal(genDoc)
99-
assert.NoError(t, err, "error marshalling genDoc")
99+
assert.NoError(t, err, "error marshaling genDoc")
100100
genDoc, err = GenesisDocFromJSON(genDocBytes)
101101
assert.NoError(t, err, "expected no error for valid genDoc json")
102102

103103
// test with invalid consensus params
104104
genDoc.ConsensusParams.Block.MaxBytes = 0
105105
genDocBytes, err = tmjson.Marshal(genDoc)
106-
assert.NoError(t, err, "error marshalling genDoc")
106+
assert.NoError(t, err, "error marshaling genDoc")
107107
_, err = GenesisDocFromJSON(genDocBytes)
108108
assert.Error(t, err, "expected error for genDoc json with block size of 0")
109109

‎types/signable.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ var (
1717
// SignBytes returns the bytes to be signed
1818
// NOTE: chainIDs are part of the SignBytes but not
1919
// necessarily the object themselves.
20-
// NOTE: Expected to panic if there is an error marshalling.
20+
// NOTE: Expected to panic if there is an error marshaling.
2121
type Signable interface {
2222
SignBytes(chainID string) []byte
2323
}

‎types/validator_set_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,9 @@ func TestAveragingInIncrementProposerPriority(t *testing.T) {
492492
{Address: []byte("c"), ProposerPriority: 1}}},
493493
// this should average twice but the average should be 0 after the first iteration
494494
// (voting power is 0 -> no changes)
495-
11, 1 / 3},
495+
11,
496+
0, // 1 / 3
497+
},
496498
2: {ValidatorSet{
497499
Validators: []*Validator{
498500
{Address: []byte("a"), ProposerPriority: 100},

0 commit comments

Comments
 (0)
Please sign in to comment.