Browse Source

lint: cleanup pending lint errors (#7237)

pull/7233/head
Sam Kleinman 3 years ago
committed by GitHub
parent
commit
4ef140f6ca
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 65 additions and 46 deletions
  1. +11
    -3
      .golangci.yml
  2. +1
    -1
      abci/types/result.go
  3. +1
    -1
      consensus/reactor.go
  4. +1
    -0
      consensus/wal_fuzz.go
  5. +1
    -1
      crypto/secp256k1/secp256k1.go
  6. +1
    -0
      crypto/secp256k1/secp256k1_nocgo.go
  7. +1
    -1
      crypto/secp256k1/secp256k1_test.go
  8. +1
    -1
      crypto/xchacha20poly1305/xchachapoly_test.go
  9. +1
    -1
      libs/bytes/bytes.go
  10. +2
    -1
      libs/events/event_cache_test.go
  11. +0
    -1
      libs/json/helpers_test.go
  12. +1
    -1
      libs/protoio/io_test.go
  13. +9
    -8
      libs/pubsub/subscription.go
  14. +1
    -0
      libs/sync/deadlock.go
  15. +1
    -0
      libs/sync/sync.go
  16. +1
    -1
      light/store/db/db.go
  17. +1
    -1
      node/node_test.go
  18. +1
    -0
      p2p/conn/conn_go110.go
  19. +1
    -0
      p2p/conn/conn_notgo110.go
  20. +2
    -1
      p2p/conn/secret_connection_test.go
  21. +4
    -4
      p2p/netaddress.go
  22. +3
    -3
      privval/socket_listeners.go
  23. +1
    -1
      rpc/client/helpers.go
  24. +1
    -0
      rpc/jsonrpc/client/integration_test.go
  25. +1
    -1
      rpc/jsonrpc/types/types.go
  26. +2
    -2
      state/state.go
  27. +1
    -1
      state/state_test.go
  28. +1
    -1
      state/store.go
  29. +1
    -1
      state/txindex/indexer_service.go
  30. +2
    -2
      state/validation_test.go
  31. +1
    -1
      test/e2e/app/state.go
  32. +1
    -1
      types/event_bus.go
  33. +3
    -3
      types/genesis_test.go
  34. +1
    -1
      types/signable.go
  35. +3
    -1
      types/validator_set_test.go

+ 11
- 3
.golangci.yml View File

@ -26,14 +26,14 @@ linters:
# - interfacer
- lll
# - maligned
- misspell
# - misspell
- nakedret
- nolintlint
- prealloc
- staticcheck
- structcheck
- stylecheck
- typecheck
# - typecheck
- unconvert
# - unparam
- unused
@ -54,9 +54,17 @@ issues:
linters-settings:
dogsled:
max-blank-identifiers: 3
golint:
maligned:
suggest-new: true
# govet:
# check-shadowing: true
revive:
min-confidence: 0
maligned:
suggest-new: true
misspell:
locale: US
ignore-words:
- behaviour

+ 1
- 1
abci/types/result.go View File

@ -42,7 +42,7 @@ func (r ResponseQuery) IsErr() bool {
}
//---------------------------------------------------------------------------
// override JSON marshalling so we emit defaults (ie. disable omitempty)
// override JSON marshaling so we emit defaults (ie. disable omitempty)
var (
jsonpbMarshaller = jsonpb.Marshaler{


+ 1
- 1
consensus/reactor.go View File

@ -1476,7 +1476,7 @@ func (m *NewRoundStepMessage) ValidateHeight(initialHeight int64) error {
m.LastCommitRound, initialHeight)
}
if m.Height > initialHeight && m.LastCommitRound < 0 {
return fmt.Errorf("LastCommitRound can only be negative for initial height %v", // nolint
return fmt.Errorf("LastCommitRound can only be negative for initial height %v",
initialHeight)
}
return nil


+ 1
- 0
consensus/wal_fuzz.go View File

@ -1,3 +1,4 @@
//go:build gofuzz
// +build gofuzz
package consensus


+ 1
- 1
crypto/secp256k1/secp256k1.go View File

@ -152,7 +152,7 @@ func (pubKey PubKey) Address() crypto.Address {
return crypto.Address(hasherRIPEMD160.Sum(nil))
}
// Bytes returns the pubkey marshalled with amino encoding.
// Bytes returns the pubkey marshaled with amino encoding.
func (pubKey PubKey) Bytes() []byte {
return []byte(pubKey)
}


+ 1
- 0
crypto/secp256k1/secp256k1_nocgo.go View File

@ -1,3 +1,4 @@
//go:build !libsecp256k1
// +build !libsecp256k1
package secp256k1


+ 1
- 1
crypto/secp256k1/secp256k1_test.go View File

@ -36,7 +36,7 @@ func TestPubKeySecp256k1Address(t *testing.T) {
addrBbz, _, _ := base58.CheckDecode(d.addr)
addrB := crypto.Address(addrBbz)
var priv secp256k1.PrivKey = secp256k1.PrivKey(privB)
priv := secp256k1.PrivKey(privB)
pubKey := priv.PubKey()
pubT, _ := pubKey.(secp256k1.PubKey)


+ 1
- 1
crypto/xchacha20poly1305/xchachapoly_test.go View File

@ -83,7 +83,7 @@ func TestRandom(t *testing.T) {
}
}
// AFOREMENTIONED LICENCE
// AFOREMENTIONED LICENSE
// Copyright (c) 2009 The Go Authors. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without


+ 1
- 1
libs/bytes/bytes.go View File

@ -43,7 +43,7 @@ func (bz *HexBytes) UnmarshalJSON(data []byte) error {
return nil
}
// Bytes fulfils various interfaces in light-client, etc...
// Bytes fulfills various interfaces in light-client, etc...
func (bz HexBytes) Bytes() []byte {
return bz
}


+ 2
- 1
libs/events/event_cache_test.go View File

@ -13,7 +13,8 @@ func TestEventCache_Flush(t *testing.T) {
require.NoError(t, err)
err = evsw.AddListenerForEvent("nothingness", "", func(data EventData) {
// Check we are not initialising an empty buffer full of zeroed eventInfos in the EventCache
// Check we are not initializing an empty buffer full
// of zeroed eventInfos in the EventCache
require.FailNow(t, "We should never receive a message on this switch since none are fired")
})
require.NoError(t, err)


+ 0
- 1
libs/json/helpers_test.go View File

@ -61,7 +61,6 @@ func (c CustomValue) MarshalJSON() ([]byte, error) {
}
func (c CustomValue) UnmarshalJSON(bz []byte) error {
c.Value = "custom"
return nil
}


+ 1
- 1
libs/protoio/io_test.go View File

@ -71,7 +71,7 @@ func iotest(writer protoio.WriteCloser, reader protoio.ReadCloser) error {
return err
}
if n != len(bz)+visize {
return fmt.Errorf("WriteMsg() wrote %v bytes, expected %v", n, len(bz)+visize) // nolint
return fmt.Errorf("WriteMsg() wrote %v bytes, expected %v", n, len(bz)+visize)
}
lens[i] = n
}


+ 9
- 8
libs/pubsub/subscription.go View File

@ -23,16 +23,16 @@ var (
type Subscription struct {
out chan Message
cancelled chan struct{}
mtx tmsync.RWMutex
err error
canceled chan struct{}
mtx tmsync.RWMutex
err error
}
// NewSubscription returns a new subscription with the given outCapacity.
func NewSubscription(outCapacity int) *Subscription {
return &Subscription{
out: make(chan Message, outCapacity),
cancelled: make(chan struct{}),
out: make(chan Message, outCapacity),
canceled: make(chan struct{}),
}
}
@ -43,13 +43,14 @@ 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{} {
return s.cancelled
return s.canceled
}
// Err returns nil if the channel returned by Cancelled is not yet closed.
// Err returns nil if the channel returned is not yet closed.
// If the channel is closed, Err returns a non-nil error explaining why:
// - ErrUnsubscribed if the subscriber choose to unsubscribe,
// - ErrOutOfCapacity if the subscriber is not pulling messages fast enough
@ -66,7 +67,7 @@ func (s *Subscription) cancel(err error) {
s.mtx.Lock()
s.err = err
s.mtx.Unlock()
close(s.cancelled)
close(s.canceled)
}
// Message glues data and events together.


+ 1
- 0
libs/sync/deadlock.go View File

@ -1,3 +1,4 @@
//go:build deadlock
// +build deadlock
package sync


+ 1
- 0
libs/sync/sync.go View File

@ -1,3 +1,4 @@
//go:build !deadlock
// +build !deadlock
package sync


+ 1
- 1
light/store/db/db.go View File

@ -54,7 +54,7 @@ func (s *dbs) SaveLightBlock(lb *types.LightBlock) error {
lbBz, err := lbpb.Marshal()
if err != nil {
return fmt.Errorf("marshalling LightBlock: %w", err)
return fmt.Errorf("marshaling LightBlock: %w", err)
}
s.mtx.Lock()


+ 1
- 1
node/node_test.go View File

@ -262,7 +262,7 @@ func TestCreateProposalBlock(t *testing.T) {
// fill the evidence pool with more evidence
// than can fit in a block
var currentBytes int64 = 0
var currentBytes int64
for currentBytes <= maxEvidenceBytes {
ev := types.NewMockDuplicateVoteEvidenceWithValidator(height, time.Now(), privVals[0], "test-chain")
currentBytes += int64(len(ev.Bytes()))


+ 1
- 0
p2p/conn/conn_go110.go View File

@ -1,3 +1,4 @@
//go:build go1.10
// +build go1.10
package conn


+ 1
- 0
p2p/conn/conn_notgo110.go View File

@ -1,3 +1,4 @@
//go:build !go1.10
// +build !go1.10
package conn


+ 2
- 1
p2p/conn/secret_connection_test.go View File

@ -194,7 +194,8 @@ func TestSecretConnectionReadWrite(t *testing.T) {
compareWritesReads := func(writes []string, reads []string) {
for {
// Pop next write & corresponding reads
var read, write string = "", writes[0]
var read = ""
var write = writes[0]
var readCount = 0
for _, readChunk := range reads {
read += readChunk


+ 4
- 4
p2p/netaddress.go View File

@ -316,10 +316,10 @@ func (na *NetAddress) ReachabilityTo(o *NetAddress) int {
}
return Default
default: /* ipv6 */
var tunnelled bool
// Is our v6 is tunnelled?
var tunneled bool
// Is our v6 is tunneled?
if o.RFC3964() || o.RFC6052() || o.RFC6145() {
tunnelled = true
tunneled = true
}
switch {
case !o.Routable():
@ -328,7 +328,7 @@ func (na *NetAddress) ReachabilityTo(o *NetAddress) int {
return Teredo
case o.IP.To4() != nil:
return Ipv4
case tunnelled:
case tunneled:
// only prioritise ipv6 if we aren't tunnelling it.
return Ipv6Weak
}


+ 3
- 3
privval/socket_listeners.go View File

@ -39,7 +39,7 @@ func TCPListenerTimeoutReadWrite(timeout time.Duration) TCPListenerOption {
// tcpListener implements net.Listener.
var _ net.Listener = (*TCPListener)(nil)
// TCPListener wraps a *net.TCPListener to standardise protocol timeouts
// TCPListener wraps a *net.TCPListener to standardize protocol timeouts
// and potentially other tuning parameters. It also returns encrypted connections.
type TCPListener struct {
*net.TCPListener
@ -104,7 +104,7 @@ func UnixListenerTimeoutReadWrite(timeout time.Duration) UnixListenerOption {
return func(ul *UnixListener) { ul.timeoutReadWrite = timeout }
}
// UnixListener wraps a *net.UnixListener to standardise protocol timeouts
// UnixListener wraps a *net.UnixListener to standardize protocol timeouts
// and potentially other tuning parameters. It returns unencrypted connections.
type UnixListener struct {
*net.UnixListener
@ -151,7 +151,7 @@ func (ln *UnixListener) Accept() (net.Conn, error) {
// timeoutConn implements net.Conn.
var _ net.Conn = (*timeoutConn)(nil)
// timeoutConn wraps a net.Conn to standardise protocol timeouts / deadline resets.
// timeoutConn wraps a net.Conn to standardize protocol timeouts / deadline resets.
type timeoutConn struct {
net.Conn
timeout time.Duration


+ 1
- 1
rpc/client/helpers.go View File

@ -76,7 +76,7 @@ func WaitForOneEvent(c EventsClient, evtTyp string, timeout time.Duration) (type
select {
case event := <-eventCh:
return event.Data.(types.TMEventData), nil
return event.Data, nil
case <-ctx.Done():
return nil, errors.New("timed out waiting for event")
}


+ 1
- 0
rpc/jsonrpc/client/integration_test.go View File

@ -1,3 +1,4 @@
//go:build release
// +build release
// The code in here is comprehensive as an integration


+ 1
- 1
rpc/jsonrpc/types/types.go View File

@ -191,7 +191,7 @@ func NewRPCSuccessResponse(id jsonrpcid, res interface{}) RPCResponse {
var js []byte
js, err := tmjson.Marshal(res)
if err != nil {
return RPCInternalError(id, fmt.Errorf("error marshalling response: %w", err))
return RPCInternalError(id, fmt.Errorf("error marshaling response: %w", err))
}
rawMsg = json.RawMessage(js)
}


+ 2
- 2
state/state.go View File

@ -175,8 +175,8 @@ func (state *State) ToProto() (*tmstate.State, error) {
return sm, nil
}
// StateFromProto takes a state proto message & returns the local state type
func StateFromProto(pb *tmstate.State) (*State, error) { //nolint:golint
// FromProto takes a state proto message & returns the local state type
func FromProto(pb *tmstate.State) (*State, error) { //nolint:golint
if pb == nil {
return nil, errors.New("nil State")
}


+ 1
- 1
state/state_test.go View File

@ -1075,7 +1075,7 @@ func TestStateProto(t *testing.T) {
assert.NoError(t, err, tt.testName)
}
smt, err := sm.StateFromProto(pbs)
smt, err := sm.FromProto(pbs)
if tt.expPass2 {
require.NoError(t, err, tt.testName)
require.Equal(t, tt.state, smt, tt.testName)


+ 1
- 1
state/store.go View File

@ -142,7 +142,7 @@ func (store dbStore) loadState(key []byte) (state State, err error) {
%v\n`, err))
}
sm, err := StateFromProto(sp)
sm, err := FromProto(sp)
if err != nil {
return state, err
}


+ 1
- 1
state/txindex/indexer_service.go View File

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


+ 2
- 2
state/validation_test.go View File

@ -240,7 +240,7 @@ func TestValidateBlockEvidence(t *testing.T) {
A block with too much evidence fails
*/
evidence := make([]types.Evidence, 0)
var currentBytes int64 = 0
var currentBytes int64
// more bytes than the maximum allowed for evidence
for currentBytes <= maxBytesEvidence {
newEv := types.NewMockDuplicateVoteEvidenceWithValidator(height, time.Now(),
@ -260,7 +260,7 @@ func TestValidateBlockEvidence(t *testing.T) {
A good block with several pieces of good evidence passes
*/
evidence := make([]types.Evidence, 0)
var currentBytes int64 = 0
var currentBytes int64
// precisely the amount of allowed evidence
for {
newEv := types.NewMockDuplicateVoteEvidenceWithValidator(height, defaultEvidenceTime,


+ 1
- 1
test/e2e/app/state.go View File

@ -19,7 +19,7 @@ type State struct {
Values map[string]string
Hash []byte
// private fields aren't marshalled to disk.
// private fields aren't marshaled to disk.
file string
persistInterval uint64
initialHeight uint64


+ 1
- 1
types/event_bus.go View File

@ -23,7 +23,7 @@ type EventBusSubscriber interface {
type Subscription interface {
Out() <-chan tmpubsub.Message
Cancelled() <-chan struct{}
Cancelled() <-chan struct{} // nolint: misspell
Err() error
}


+ 3
- 3
types/genesis_test.go View File

@ -84,7 +84,7 @@ func TestGenesisGood(t *testing.T) {
Validators: []GenesisValidator{{pubkey.Address(), pubkey, 10, "myval"}},
}
genDocBytes, err = tmjson.Marshal(baseGenDoc)
assert.NoError(t, err, "error marshalling genDoc")
assert.NoError(t, err, "error marshaling genDoc")
// test base gendoc and check consensus params were filled
genDoc, err := GenesisDocFromJSON(genDocBytes)
@ -96,14 +96,14 @@ func TestGenesisGood(t *testing.T) {
// create json with consensus params filled
genDocBytes, err = tmjson.Marshal(genDoc)
assert.NoError(t, err, "error marshalling genDoc")
assert.NoError(t, err, "error marshaling genDoc")
genDoc, err = GenesisDocFromJSON(genDocBytes)
assert.NoError(t, err, "expected no error for valid genDoc json")
// test with invalid consensus params
genDoc.ConsensusParams.Block.MaxBytes = 0
genDocBytes, err = tmjson.Marshal(genDoc)
assert.NoError(t, err, "error marshalling genDoc")
assert.NoError(t, err, "error marshaling genDoc")
_, err = GenesisDocFromJSON(genDocBytes)
assert.Error(t, err, "expected error for genDoc json with block size of 0")


+ 1
- 1
types/signable.go View File

@ -17,7 +17,7 @@ var (
// SignBytes returns the bytes to be signed
// NOTE: chainIDs are part of the SignBytes but not
// necessarily the object themselves.
// NOTE: Expected to panic if there is an error marshalling.
// NOTE: Expected to panic if there is an error marshaling.
type Signable interface {
SignBytes(chainID string) []byte
}

+ 3
- 1
types/validator_set_test.go View File

@ -492,7 +492,9 @@ func TestAveragingInIncrementProposerPriority(t *testing.T) {
{Address: []byte("c"), ProposerPriority: 1}}},
// this should average twice but the average should be 0 after the first iteration
// (voting power is 0 -> no changes)
11, 1 / 3},
11,
0, // 1 / 3
},
2: {ValidatorSet{
Validators: []*Validator{
{Address: []byte("a"), ProposerPriority: 100},


Loading…
Cancel
Save