lint add deadcode unused (#4606)
Added deadcode and unused linters to the repo, it helped find some unused code. Ref #4589
This commit is contained in:
parent
6672e70556
commit
4ffabb65a5
|
@ -7,6 +7,8 @@ linters:
|
|||
- unconvert
|
||||
- misspell
|
||||
- govet
|
||||
- unused
|
||||
- deadcode
|
||||
- goconst
|
||||
linters-settings:
|
||||
gocyclo:
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
package keys
|
||||
|
||||
import "fmt"
|
||||
|
||||
func errKeyNameConflict(name string) error {
|
||||
return fmt.Errorf("account with name %s already exists", name)
|
||||
}
|
||||
|
||||
func errMissingName() error {
|
||||
return fmt.Errorf("you have to specify a name for the locally stored account")
|
||||
}
|
||||
|
||||
func errMissingPassword() error {
|
||||
return fmt.Errorf("you have to specify a password for the locally stored account")
|
||||
}
|
||||
|
||||
func errMissingMnemonic() error {
|
||||
return fmt.Errorf("you have to specify a mnemonic for key recovery")
|
||||
}
|
||||
|
||||
func errInvalidMnemonic() error {
|
||||
return fmt.Errorf("the mnemonic is invalid")
|
||||
}
|
||||
|
||||
func errInvalidAccountNumber() error {
|
||||
return fmt.Errorf("the account number is invalid")
|
||||
}
|
||||
|
||||
func errInvalidIndexNumber() error {
|
||||
return fmt.Errorf("the index number is invalid")
|
||||
}
|
|
@ -30,9 +30,8 @@ type RestServer struct {
|
|||
CliCtx context.CLIContext
|
||||
KeyBase keybase.Keybase
|
||||
|
||||
log log.Logger
|
||||
listener net.Listener
|
||||
fingerprint string
|
||||
log log.Logger
|
||||
listener net.Listener
|
||||
}
|
||||
|
||||
// NewRestServer creates a new rest server instance
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package cachekv
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"container/list"
|
||||
|
||||
cmn "github.com/tendermint/tendermint/libs/common"
|
||||
|
@ -84,17 +83,3 @@ func (mi *memIterator) Close() {
|
|||
mi.end = nil
|
||||
mi.items = nil
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
// Misc.
|
||||
|
||||
// bytes.Compare but bounded on both sides by nil.
|
||||
// both (k1, nil) and (nil, k2) return -1
|
||||
func keyCompare(k1, k2 []byte) int {
|
||||
if k1 == nil && k2 == nil {
|
||||
return 0
|
||||
} else if k1 == nil || k2 == nil {
|
||||
return -1
|
||||
}
|
||||
return bytes.Compare(k1, k2)
|
||||
}
|
||||
|
|
|
@ -103,10 +103,3 @@ func (m List) Iterate(ptr interface{}, fn func(uint64) bool) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func subspace(prefix []byte) (start, end []byte) {
|
||||
end = make([]byte, len(prefix))
|
||||
copy(end, prefix)
|
||||
end[len(end)-1]++
|
||||
return prefix, end
|
||||
}
|
||||
|
|
|
@ -188,31 +188,3 @@ func stripPrefix(key []byte, prefix []byte) []byte {
|
|||
func cpIncr(bz []byte) []byte {
|
||||
return types.PrefixEndBytes(bz)
|
||||
}
|
||||
|
||||
// copied from github.com/tendermint/tendermint/libs/db/util.go
|
||||
func cpDecr(bz []byte) (ret []byte) {
|
||||
if len(bz) == 0 {
|
||||
panic("cpDecr expects non-zero bz length")
|
||||
}
|
||||
ret = make([]byte, len(bz))
|
||||
copy(ret, bz)
|
||||
for i := len(bz) - 1; i >= 0; i-- {
|
||||
if ret[i] > byte(0x00) {
|
||||
ret[i]--
|
||||
return
|
||||
}
|
||||
ret[i] = byte(0xFF)
|
||||
if i == 0 {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func skipOne(iter types.Iterator, skipKey []byte) {
|
||||
if iter.Valid() {
|
||||
if bytes.Equal(iter.Key(), skipKey) {
|
||||
iter.Next()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,11 +14,6 @@ const (
|
|||
GasDeleteDesc = "Delete"
|
||||
)
|
||||
|
||||
var (
|
||||
cachedKVGasConfig = KVGasConfig()
|
||||
cachedTransientGasConfig = TransientGasConfig()
|
||||
)
|
||||
|
||||
// Gas measured by the SDK
|
||||
type Gas = uint64
|
||||
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
package store
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
)
|
||||
|
||||
var cdc = codec.New()
|
|
@ -569,12 +569,6 @@ func removeZeroCoins(coins Coins) Coins {
|
|||
return coins[:i]
|
||||
}
|
||||
|
||||
func copyCoins(coins Coins) Coins {
|
||||
copyCoins := make(Coins, len(coins))
|
||||
copy(copyCoins, coins)
|
||||
return copyCoins
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Sort interface
|
||||
|
||||
|
|
|
@ -301,6 +301,7 @@ func AppendMsgToErr(msg string, err string) string {
|
|||
}
|
||||
|
||||
// returns the index of the message in the ABCI Log
|
||||
// nolint: deadcode unused
|
||||
func mustGetMsgIndex(abciLog string) int {
|
||||
msgIdx := strings.Index(abciLog, "message\":\"")
|
||||
if msgIdx == -1 {
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
"testing"
|
||||
|
||||
"math/big"
|
||||
"math/rand"
|
||||
)
|
||||
|
||||
const maxBitLen = 255
|
||||
|
@ -37,8 +36,6 @@ func mod(i *big.Int, i2 *big.Int) *big.Int { return new(big.Int).Mod(i, i2) }
|
|||
|
||||
func neg(i *big.Int) *big.Int { return new(big.Int).Neg(i) }
|
||||
|
||||
func random(i *big.Int) *big.Int { return new(big.Int).Rand(rand.New(rand.NewSource(rand.Int63())), i) }
|
||||
|
||||
func min(i *big.Int, i2 *big.Int) *big.Int {
|
||||
if i.Cmp(i2) == 1 {
|
||||
return new(big.Int).Set(i2)
|
||||
|
|
|
@ -106,9 +106,6 @@ func MaxUint(u1, u2 Uint) Uint { return NewUintFromBigInt(max(u1.i, u2.i)) }
|
|||
// Human readable string
|
||||
func (u Uint) String() string { return u.i.String() }
|
||||
|
||||
// Testing purpose random Uint generator
|
||||
func randomUint(u Uint) Uint { return NewUintFromBigInt(random(u.i)) }
|
||||
|
||||
// MarshalAmino defines custom encoding scheme
|
||||
func (u Uint) MarshalAmino() (string, error) {
|
||||
if u.i == nil { // Necessary since default Uint initialization has i.i as nil
|
||||
|
|
|
@ -142,20 +142,6 @@ func (ak AccountKeeper) GetSequence(ctx sdk.Context, addr sdk.AccAddress) (uint6
|
|||
return acc.GetSequence(), nil
|
||||
}
|
||||
|
||||
func (ak AccountKeeper) setSequence(ctx sdk.Context, addr sdk.AccAddress, newSequence uint64) sdk.Error {
|
||||
acc := ak.GetAccount(ctx, addr)
|
||||
if acc == nil {
|
||||
return sdk.ErrUnknownAddress(fmt.Sprintf("account %s does not exist", addr))
|
||||
}
|
||||
|
||||
if err := acc.SetSequence(newSequence); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
ak.SetAccount(ctx, acc)
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetNextAccountNumber Returns and increments the global account number counter
|
||||
func (ak AccountKeeper) GetNextAccountNumber(ctx sdk.Context) uint64 {
|
||||
var accNumber uint64
|
||||
|
|
|
@ -22,6 +22,7 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/x/distribution/types"
|
||||
)
|
||||
|
||||
//nolint: deadcode unused
|
||||
var (
|
||||
delPk1 = ed25519.GenPrivKey().PubKey()
|
||||
delPk2 = ed25519.GenPrivKey().PubKey()
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
// nolint: deadcode unused
|
||||
var (
|
||||
delPk1 = ed25519.GenPrivKey().PubKey()
|
||||
delPk2 = ed25519.GenPrivKey().PubKey()
|
||||
|
|
|
@ -22,8 +22,6 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/x/staking"
|
||||
)
|
||||
|
||||
const flagGenTxDir = "gentx-dir"
|
||||
|
||||
// common config options for init
|
||||
type InitConfig struct {
|
||||
ChainID string
|
||||
|
|
|
@ -14,15 +14,6 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/x/staking"
|
||||
)
|
||||
|
||||
var (
|
||||
defaultTokens = sdk.TokensFromConsensusPower(100)
|
||||
defaultAmount = defaultTokens.String() + sdk.DefaultBondDenom
|
||||
defaultCommissionRate = "0.1"
|
||||
defaultCommissionMaxRate = "0.2"
|
||||
defaultCommissionMaxChangeRate = "0.01"
|
||||
defaultMinSelfDelegation = "1"
|
||||
)
|
||||
|
||||
// ValidateAccountInGenesis checks that the provided key has sufficient
|
||||
// coins in the genesis accounts
|
||||
func ValidateAccountInGenesis(appGenesisState map[string]json.RawMessage,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// nolint:deadcode unused
|
||||
package gov
|
||||
|
||||
import (
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// nolint:deadcode unused
|
||||
package keeper
|
||||
|
||||
import (
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// nolint: deadcode unused
|
||||
package params
|
||||
|
||||
import (
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// nolint:deadcode unused
|
||||
package slashing
|
||||
|
||||
import (
|
||||
|
|
|
@ -43,7 +43,6 @@ var (
|
|||
FsMinSelfDelegation = flag.NewFlagSet("", flag.ContinueOnError)
|
||||
fsDescriptionEdit = flag.NewFlagSet("", flag.ContinueOnError)
|
||||
fsValidator = flag.NewFlagSet("", flag.ContinueOnError)
|
||||
fsDelegator = flag.NewFlagSet("", flag.ContinueOnError)
|
||||
fsRedelegation = flag.NewFlagSet("", flag.ContinueOnError)
|
||||
)
|
||||
|
||||
|
|
|
@ -26,11 +26,10 @@ import (
|
|||
)
|
||||
|
||||
// dummy addresses used for testing
|
||||
// nolint: unused deadcode
|
||||
var (
|
||||
Addrs = createTestAddrs(500)
|
||||
PKs = createTestPubKeys(500)
|
||||
emptyAddr sdk.AccAddress
|
||||
emptyPubkey crypto.PubKey
|
||||
Addrs = createTestAddrs(500)
|
||||
PKs = createTestPubKeys(500)
|
||||
|
||||
addrDels = []sdk.AccAddress{
|
||||
Addrs[0],
|
||||
|
@ -258,6 +257,7 @@ func TestingUpdateValidator(keeper Keeper, ctx sdk.Context, validator types.Vali
|
|||
return validator
|
||||
}
|
||||
|
||||
// nolint: deadcode unused
|
||||
func validatorByPowerIndexExists(k Keeper, ctx sdk.Context, power []byte) bool {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
return store.Has(power)
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
)
|
||||
|
||||
// nolint: deadcode unused
|
||||
var (
|
||||
priv1 = secp256k1.GenPrivKey()
|
||||
addr1 = sdk.AccAddress(priv1.PubKey().Address())
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
// nolint: deadcode unused
|
||||
var (
|
||||
pk1 = ed25519.GenPrivKey().PubKey()
|
||||
pk2 = ed25519.GenPrivKey().PubKey()
|
||||
|
|
Loading…
Reference in New Issue