Skip to content

Commit 21b808b

Browse files
committed
fix lint
1 parent 4eb6bd9 commit 21b808b

19 files changed

Lines changed: 28 additions & 27 deletions

File tree

blocksync/reactor_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ func TestBadBlockStopsPeer(t *testing.T) {
261261
require.NoError(t, err)
262262
}()
263263

264-
reactorPairs := make([]ReactorPair, 4)
264+
reactorPairs := make([]ReactorPair, 4) //nolint:prealloc
265265

266266
reactorPairs[0] = newReactor(t, log.TestingLogger(), genDoc, privVals, maxBlockHeight)
267267
reactorPairs[1] = newReactor(t, log.TestingLogger(), genDoc, privVals, 0)
@@ -344,7 +344,7 @@ func TestCheckSwitchToConsensusLastHeightZero(t *testing.T) {
344344

345345
reactorPairs = append(reactorPairs, newReactor(t, log.TestingLogger(), genDoc, privVals, maxBlockHeight))
346346

347-
var switches []*p2p.Switch
347+
var switches []*p2p.Switch //nolint:prealloc
348348
for _, r := range reactorPairs {
349349
switches = append(switches, p2p.MakeConnectedSwitches(config.P2P, 1, func(i int, s *p2p.Switch) *p2p.Switch {
350350
s.AddReactor("BLOCKSYNC", r.reactor)
@@ -410,7 +410,7 @@ func ExtendedCommitNetworkHelper(t *testing.T, maxBlockHeight int64, enableVoteE
410410

411411
reactorPairs = append(reactorPairs, newReactor(t, log.TestingLogger(), genDoc, privVals, maxBlockHeight, invalidBlockHeightAt))
412412

413-
var switches []*p2p.Switch
413+
var switches []*p2p.Switch //nolint:prealloc
414414
for _, r := range reactorPairs {
415415
switches = append(switches, p2p.MakeConnectedSwitches(config.P2P, 1, func(i int, s *p2p.Switch) *p2p.Switch {
416416
s.AddReactor("BLOCKSYNC", r.reactor)

libs/bits/bit_array.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ func (bA *BitArray) UnmarshalJSON(bz []byte) error {
472472
bA2.SetIndex(i, true)
473473
}
474474
}
475-
*bA = *bA2 //nolint:govet
475+
*bA = *bA2 //nolint:govet,copylocks
476476
return nil
477477
}
478478

libs/pubsub/query/query.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func Compile(ast syntax.Query) (*Query, error) {
6464
}
6565

6666
func ExpandEvents(flattenedEvents map[string][]string) []types.Event {
67-
events := make([]types.Event, 0)
67+
events := make([]types.Event, 0) //nolint:prealloc
6868

6969
for composite, values := range flattenedEvents {
7070
tokens := strings.Split(composite, ".")

libs/pubsub/query/query_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ func TestAllMatchesAll(t *testing.T) {
443443
`Route|66=`,
444444
`Rilly|Blue=`,
445445
)
446-
keys := make([]string, 0)
446+
keys := make([]string, 0) //nolint:prealloc
447447
for k := range events {
448448
keys = append(keys, k)
449449
}

mempool/cache_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func TestCacheAfterUpdate(t *testing.T) {
7070
require.NoError(t, err)
7171
}
7272

73-
updateTxs := []types.Tx{}
73+
updateTxs := []types.Tx{} //nolint:prealloc
7474
for _, v := range tc.updateIndices {
7575
tx := kvstore.NewTx(fmt.Sprintf("%d", v), "value")
7676
updateTxs = append(updateTxs, tx)

p2p/conn/connection.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ func NewMConnectionWithConfig(
197197

198198
// Create channels
199199
channelsIdx := map[byte]*Channel{}
200-
channels := []*Channel{}
200+
channels := []*Channel{} //nolint:prealloc
201201

202202
for _, desc := range chDescs {
203203
channel := newChannel(mconn, *desc)

p2p/node_info_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func TestNodeInfoValidate(t *testing.T) {
1818
for i := 0; i < maxNumChannels; i++ {
1919
channels[i] = byte(i)
2020
}
21-
dupChannels := make([]byte, 5)
21+
dupChannels := make([]byte, 5) //nolint:prealloc
2222
copy(dupChannels, channels[:5])
2323
dupChannels = append(dupChannels, testCh)
2424

p2p/pex/addrbook.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ func (a *addrBook) addBadPeer(addr *p2p.NetAddress, banTime time.Duration) bool
831831

832832
// hash(key + sourcegroup + int64(hash(key + group + sourcegroup)) % bucket_per_group) % num_new_buckets
833833
func (a *addrBook) calcNewBucket(addr, src *p2p.NetAddress) (int, error) {
834-
data1 := []byte{}
834+
data1 := []byte{} //nolint:prealloc
835835
data1 = append(data1, []byte(a.key)...)
836836
data1 = append(data1, []byte(a.groupKey(addr))...)
837837
data1 = append(data1, []byte(a.groupKey(src))...)
@@ -843,7 +843,7 @@ func (a *addrBook) calcNewBucket(addr, src *p2p.NetAddress) (int, error) {
843843
hash64 %= newBucketsPerGroup
844844
var hashbuf [8]byte
845845
binary.BigEndian.PutUint64(hashbuf[:], hash64)
846-
data2 := []byte{}
846+
data2 := []byte{} //nolint:prealloc
847847
data2 = append(data2, []byte(a.key)...)
848848
data2 = append(data2, a.groupKey(src)...)
849849
data2 = append(data2, hashbuf[:]...)
@@ -858,7 +858,7 @@ func (a *addrBook) calcNewBucket(addr, src *p2p.NetAddress) (int, error) {
858858

859859
// hash(key + group + int64(hash(key + addr)) % buckets_per_group) % num_old_buckets
860860
func (a *addrBook) calcOldBucket(addr *p2p.NetAddress) (int, error) {
861-
data1 := []byte{}
861+
data1 := []byte{} //nolint:prealloc
862862
data1 = append(data1, []byte(a.key)...)
863863
data1 = append(data1, []byte(addr.String())...)
864864
hash1, err := a.hash(data1)
@@ -869,7 +869,7 @@ func (a *addrBook) calcOldBucket(addr *p2p.NetAddress) (int, error) {
869869
hash64 %= oldBucketsPerGroup
870870
var hashbuf [8]byte
871871
binary.BigEndian.PutUint64(hashbuf[:], hash64)
872-
data2 := []byte{}
872+
data2 := []byte{} //nolint:prealloc
873873
data2 = append(data2, []byte(a.key)...)
874874
data2 = append(data2, a.groupKey(addr)...)
875875
data2 = append(data2, hashbuf[:]...)

privval/signer_client_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type signerTestCase struct {
2525
}
2626

2727
func getSignerTestCases(t *testing.T) []signerTestCase {
28-
testCases := make([]signerTestCase, 0)
28+
testCases := make([]signerTestCase, 0) //nolint:prealloc
2929

3030
// Get test cases for each possible dialer (DialTCP / DialUnix / etc)
3131
for _, dtc := range getDialerTestCases(t) {

rpc/core/net.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func (env *Environment) UnsafeDialPeers(
100100
//nolint:govet
101101
func (env *Environment) Genesis(*rpctypes.Context) (*ctypes.ResultGenesis, error) {
102102
return nil, errors.New("endpoint is disabled due to large genesis file size")
103-
103+
//nolint:govet
104104
if len(env.genChunks) > 1 {
105105
return nil, errors.New("genesis response is large, please use the genesis_chunked API instead")
106106
}
@@ -111,6 +111,7 @@ func (env *Environment) Genesis(*rpctypes.Context) (*ctypes.ResultGenesis, error
111111
//nolint:govet
112112
func (env *Environment) GenesisChunked(_ *rpctypes.Context, chunk uint) (*ctypes.ResultGenesisChunk, error) {
113113
return nil, errors.New("endpoint is disabled due to large genesis file size")
114+
//nolint:govet
114115
if env.genChunks == nil {
115116
return nil, fmt.Errorf("service configuration error, genesis chunks are not initialized")
116117
}

0 commit comments

Comments
 (0)