Browse Source

Fix some golangci-lint warnings (#4448)

pull/4454/head
Erik Grinaker 4 years ago
committed by GitHub
parent
commit
8f48c49543
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 19 additions and 21 deletions
  1. +1
    -1
      .golangci.yml
  2. +2
    -1
      abci/tests/test_app/main.go
  3. +1
    -0
      consensus/state.go
  4. +1
    -3
      crypto/secp256k1/secp256k1.go
  5. +3
    -3
      libs/autofile/group.go
  6. +2
    -2
      lite/helpers.go
  7. +1
    -1
      node/node.go
  8. +0
    -4
      p2p/switch.go
  9. +1
    -1
      p2p/test_util.go
  10. +1
    -0
      rpc/core/routes.go
  11. +5
    -5
      types/priv_validator.go
  12. +1
    -0
      types/protobuf.go

+ 1
- 1
.golangci.yml View File

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


+ 2
- 1
abci/tests/test_app/main.go 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)


+ 1
- 0
consensus/state.go 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 {


+ 1
- 3
crypto/secp256k1/secp256k1.go 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"
)


+ 3
- 3
libs/autofile/group.go 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.


+ 2
- 2
lite/helpers.go 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...)
}


+ 1
- 1
node/node.go 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"


+ 0
- 4
p2p/switch.go 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) {


+ 1
- 1
p2p/test_util.go 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{


+ 1
- 0
rpc/core/routes.go 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"),


+ 5
- 5
types/priv_validator.go 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}}
}

+ 1
- 0
types/protobuf.go 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,


Loading…
Cancel
Save