Fix some golangci-lint warnings (#4448)

This commit is contained in:
Erik Grinaker
2020-02-20 13:43:40 +01:00
committed by GitHub
parent 8010f3b4df
commit 8f48c49543
12 changed files with 19 additions and 21 deletions

View File

@@ -23,7 +23,7 @@ linters:
- interfacer
- lll
- misspell
- maligned
# - maligned
- nakedret
- prealloc
- scopelint

View File

@@ -53,7 +53,8 @@ func testCounter() {
}
fmt.Printf("Running %s test with abci=%s\n", abciApp, abciType)
cmd := exec.Command("bash", "-c", fmt.Sprintf("abci-cli %s", abciApp))
subCommand := fmt.Sprintf("abci-cli %s", abciApp)
cmd := exec.Command("bash", "-c", subCommand)
cmd.Stdout = os.Stdout
if err := cmd.Start(); err != nil {
log.Fatalf("starting %q err: %v", abciApp, err)

View File

@@ -1644,6 +1644,7 @@ func (cs *State) tryAddVote(vote *types.Vote, peerID p2p.ID) (bool, error) {
// If the vote height is off, we'll just ignore it,
// But if it's a conflicting sig, add it to the cs.evpool.
// If it's otherwise invalid, punish peer.
// nolint: gocritic
if err == ErrVoteHeightMismatch {
return added, err
} else if voteErr, ok := err.(*types.ErrVoteConflictingVotes); ok {

View File

@@ -8,12 +8,10 @@ import (
"io"
"math/big"
"golang.org/x/crypto/ripemd160"
secp256k1 "github.com/btcsuite/btcd/btcec"
"golang.org/x/crypto/ripemd160" // nolint: staticcheck // necessary for Bitcoin address format
amino "github.com/tendermint/go-amino"
"github.com/tendermint/tendermint/crypto"
)

View File

@@ -77,7 +77,7 @@ type Group struct {
// OpenGroup creates a new Group with head at headPath. It returns an error if
// it fails to open head file.
func OpenGroup(headPath string, groupOptions ...func(*Group)) (g *Group, err error) {
func OpenGroup(headPath string, groupOptions ...func(*Group)) (*Group, error) {
dir, err := filepath.Abs(filepath.Dir(headPath))
if err != nil {
return nil, err
@@ -87,7 +87,7 @@ func OpenGroup(headPath string, groupOptions ...func(*Group)) (g *Group, err err
return nil, err
}
g = &Group{
g := &Group{
ID: "group:" + head.ID,
Head: head,
headBuf: bufio.NewWriterSize(head, 4096*10),
@@ -109,7 +109,7 @@ func OpenGroup(headPath string, groupOptions ...func(*Group)) (g *Group, err err
gInfo := g.readGroupInfo()
g.minIndex = gInfo.MinIndex
g.maxIndex = gInfo.MaxIndex
return
return g, nil
}
// GroupCheckDuration allows you to overwrite default groupCheckDuration.

View File

@@ -42,7 +42,7 @@ func (pkz privKeys) Extend(n int) privKeys {
}
// GenSecpPrivKeys produces an array of secp256k1 private keys to generate commits.
func GenSecpPrivKeys(n int) privKeys {
func genSecpPrivKeys(n int) privKeys {
res := make(privKeys, n)
for i := range res {
res[i] = secp256k1.GenPrivKey()
@@ -52,7 +52,7 @@ func GenSecpPrivKeys(n int) privKeys {
// ExtendSecp adds n more secp256k1 keys (to remove, just take a slice).
func (pkz privKeys) ExtendSecp(n int) privKeys {
extra := GenSecpPrivKeys(n)
extra := genSecpPrivKeys(n)
return append(pkz, extra...)
}

View File

@@ -6,7 +6,7 @@ import (
"fmt"
"net"
"net/http"
_ "net/http/pprof"
_ "net/http/pprof" // nolint: gosec // securely exposed on separate, optional port
"os"
"strings"
"time"

View File

@@ -584,10 +584,6 @@ func (sw *Switch) AddUnconditionalPeerIDs(ids []string) error {
return nil
}
func (sw *Switch) isPeerPersistentFn() func(*NetAddress) bool {
return sw.IsPeerPersistent
}
func (sw *Switch) IsPeerPersistent(na *NetAddress) bool {
for _, pa := range sw.persistentPeersAddrs {
if pa.Equals(na) {

View File

@@ -34,7 +34,7 @@ func AddPeerToSwitchPeerSet(sw *Switch, peer Peer) {
sw.peers.Add(peer)
}
func CreateRandomPeer(outbound bool) *peer {
func CreateRandomPeer(outbound bool) Peer {
addr, netAddr := CreateRoutableAddr()
p := &peer{
peerConn: peerConn{

View File

@@ -6,6 +6,7 @@ import (
// TODO: better system than "unsafe" prefix
// NOTE: Amino is registered in rpc/core/types/codec.go.
var Routes = map[string]*rpc.RPCFunc{
// subscribe/unsubscribe are reserved for websocket events.
"subscribe": rpc.NewWSRPCFunc(Subscribe, "query"),

View File

@@ -107,23 +107,23 @@ func (pv *MockPV) DisableChecks() {
// as MockPV has no safety checks at all.
}
type erroringMockPV struct {
type ErroringMockPV struct {
*MockPV
}
var ErroringMockPVErr = errors.New("erroringMockPV always returns an error")
// Implements PrivValidator.
func (pv *erroringMockPV) SignVote(chainID string, vote *Vote) error {
func (pv *ErroringMockPV) SignVote(chainID string, vote *Vote) error {
return ErroringMockPVErr
}
// Implements PrivValidator.
func (pv *erroringMockPV) SignProposal(chainID string, proposal *Proposal) error {
func (pv *ErroringMockPV) SignProposal(chainID string, proposal *Proposal) error {
return ErroringMockPVErr
}
// NewErroringMockPV returns a MockPV that fails on each signing request. Again, for testing only.
func NewErroringMockPV() *erroringMockPV {
return &erroringMockPV{&MockPV{ed25519.GenPrivKey(), false, false}}
func NewErroringMockPV() *ErroringMockPV {
return &ErroringMockPV{&MockPV{ed25519.GenPrivKey(), false, false}}
}

View File

@@ -27,6 +27,7 @@ const (
)
// TODO: Make non-global by allowing for registration of more pubkey types
var ABCIPubKeyTypesToAminoNames = map[string]string{
ABCIPubKeyTypeEd25519: ed25519.PubKeyAminoName,
ABCIPubKeyTypeSr25519: sr25519.PubKeyAminoName,