mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-05 21:14:53 +00:00
lint: cleanup pending lint errors (#7237)
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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{
|
||||
|
||||
@@ -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,3 +1,4 @@
|
||||
//go:build gofuzz
|
||||
// +build gofuzz
|
||||
|
||||
package consensus
|
||||
|
||||
@@ -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,3 +1,4 @@
|
||||
//go:build !libsecp256k1
|
||||
// +build !libsecp256k1
|
||||
|
||||
package secp256k1
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -61,7 +61,6 @@ func (c CustomValue) MarshalJSON() ([]byte, error) {
|
||||
}
|
||||
|
||||
func (c CustomValue) UnmarshalJSON(bz []byte) error {
|
||||
c.Value = "custom"
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ var (
|
||||
type Subscription struct {
|
||||
out chan Message
|
||||
|
||||
cancelled chan struct{}
|
||||
canceled chan struct{}
|
||||
mtx tmsync.RWMutex
|
||||
err error
|
||||
}
|
||||
@@ -32,7 +32,7 @@ type Subscription struct {
|
||||
func NewSubscription(outCapacity int) *Subscription {
|
||||
return &Subscription{
|
||||
out: make(chan Message, outCapacity),
|
||||
cancelled: make(chan struct{}),
|
||||
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,3 +1,4 @@
|
||||
//go:build deadlock
|
||||
// +build deadlock
|
||||
|
||||
package sync
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
//go:build !deadlock
|
||||
// +build !deadlock
|
||||
|
||||
package sync
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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,3 +1,4 @@
|
||||
//go:build go1.10
|
||||
// +build go1.10
|
||||
|
||||
package conn
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
//go:build !go1.10
|
||||
// +build !go1.10
|
||||
|
||||
package conn
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,3 +1,4 @@
|
||||
//go:build release
|
||||
// +build release
|
||||
|
||||
// The code in here is comprehensive as an integration
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -23,7 +23,7 @@ type EventBusSubscriber interface {
|
||||
|
||||
type Subscription interface {
|
||||
Out() <-chan tmpubsub.Message
|
||||
Cancelled() <-chan struct{}
|
||||
Cancelled() <-chan struct{} // nolint: misspell
|
||||
Err() error
|
||||
}
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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},
|
||||
|
||||
Reference in New Issue
Block a user