Merge PR #5192: golangcI-lint updates & set static version to 1.19

This commit is contained in:
Marko 2019-10-14 17:43:19 +02:00 committed by Alexander Bezobchuk
parent fbd551da98
commit 9f3789157e
35 changed files with 77 additions and 91 deletions

View File

@ -1,23 +1,33 @@
run:
deadline: 1m
# run:
# # timeout for analysis, e.g. 30s, 5m, default is 1m
# timeout: 5m
linters:
enable-all: true
disable:
- gocyclo
- gochecknoinits
- gochecknoglobals
- dupl
- interfacer
- unparam
- lll
enable:
- bodyclose
- deadcode
- depguard
- dogsled
- goconst
- gocritic
- gofmt
- goimports
- golint
- gosec
- gosimple
- govet
- ineffassign
- maligned
- misspell
- nakedret
- prealloc
- staticcheck
- structcheck
- typecheck
- unconvert
- unused
disable:
- errcheck
- scopelint
- varcheck
- godox
- funlen
- whitespace
issues:
exclude-rules:
@ -37,3 +47,9 @@ issues:
linters-settings:
dogsled:
max-blank-identifiers: 3
maligned:
# print struct with more effective memory layout or not, false by default
suggest-new: true
service:
golangci-lint-version: 1.19.x

View File

@ -53,7 +53,7 @@ type (
)
// BaseApp reflects the ABCI application implementation.
type BaseApp struct {
type BaseApp struct { // nolint: maligned
// initialized on creation
logger log.Logger
name string // application name from abci.Info
@ -631,7 +631,6 @@ func (app *BaseApp) runTx(mode runTxMode, txBytes []byte, tx sdk.Tx) (result sdk
}
// runMsgs iterates through all the messages and executes them.
// nolint: gocyclo
func (app *BaseApp) runMsgs(ctx sdk.Context, msgs []sdk.Msg, mode runTxMode) (result sdk.Result) {
msgLogs := make(sdk.ABCIMessageLogs, 0, len(msgs))

View File

@ -10,17 +10,16 @@ import (
var isAlphaNumeric = regexp.MustCompile(`^[a-zA-Z0-9]+$`).MatchString
// nolint - Mostly for testing
// Mostly for testing
func (app *BaseApp) Check(tx sdk.Tx) (result sdk.Result) {
return app.runTx(runTxModeCheck, nil, tx)
}
// nolint - full tx execution
// full tx execution
func (app *BaseApp) Simulate(txBytes []byte, tx sdk.Tx) (result sdk.Result) {
return app.runTx(runTxModeSimulate, txBytes, tx)
}
// nolint
func (app *BaseApp) Deliver(tx sdk.Tx) (result sdk.Result) {
return app.runTx(runTxModeDeliver, nil, tx)
}

View File

@ -23,7 +23,7 @@ import (
// CLIContext implements a typical CLI context created in SDK modules for
// transaction handling and queries.
type CLIContext struct {
Codec *codec.Codec
FromAddress sdk.AccAddress
Client rpcclient.Client
ChainID string
Keybase cryptokeys.Keybase
@ -33,14 +33,14 @@ type CLIContext struct {
HomeDir string
NodeURI string
From string
TrustNode bool
UseLedger bool
BroadcastMode string
Verifier tmlite.Verifier
FromName string
Codec *codec.Codec
TrustNode bool
UseLedger bool
Simulate bool
GenerateOnly bool
FromAddress sdk.AccAddress
FromName string
Indent bool
SkipConfirm bool
}

View File

@ -18,7 +18,7 @@ type testCases struct {
func getTestCases() testCases {
return testCases{
// nolint: govet
// nolint:govet
[]keys.KeyOutput{
{"A", "B", "C", "D", "E", 0, nil},
{"A", "B", "C", "D", "", 0, nil},

View File

@ -47,7 +47,7 @@ func checkAminoJSON(t *testing.T, src interface{}, dst interface{}, isNil bool)
require.Nil(t, err, "%+v", err)
}
// nolint: vet
// nolint: govet
func ExamplePrintRegisteredTypes() {
cdc.PrintTypes(os.Stdout)
// Output: | Type | Name | Prefix | Length | Notes |

View File

@ -50,7 +50,6 @@ func NewParams(purpose, coinType, account uint32, change bool, addressIdx uint32
}
// Parse the BIP44 path and unmarshal into the struct.
// nolint: gocyclo
func NewParamsFromPath(path string) (*BIP44Params, error) {
spl := strings.Split(path, "/")
if len(spl) != 5 {

View File

@ -19,7 +19,7 @@ func mnemonicToSeed(mnemonic string) []byte {
return bip39.NewSeed(mnemonic, defaultBIP39Passphrase)
}
// nolint: vet
// nolint:govet
func ExampleStringifyPathParams() {
path := NewParams(44, 0, 0, false, 0)
fmt.Println(path.String())
@ -101,7 +101,7 @@ func TestParamsFromPath(t *testing.T) {
}
// nolint: vet
// nolint:govet
func ExampleSomeBIP32TestVecs() {
seed := mnemonicToSeed("barrel original fuel morning among eternal " +

View File

@ -69,16 +69,16 @@ var (
//
// NOTE: dbKeybase will be deprecated in favor of keyringKeybase.
type dbKeybase struct {
db dbm.DB
base baseKeybase
db dbm.DB
}
// newDBKeybase creates a new dbKeybase instance using the provided DB for
// reading and writing keys.
func newDBKeybase(db dbm.DB) Keybase {
return dbKeybase{
db: db,
base: baseKeybase{},
db: db,
}
}

View File

@ -31,8 +31,8 @@ var _ Keybase = keyringKeybase{}
// keyringKeybase implements the Keybase interface by using the Keyring library
// for account key persistence.
type keyringKeybase struct {
db keyring.Keyring
base baseKeybase
db keyring.Keyring
}
var maxPassphraseEntryAttempts = 3
@ -453,7 +453,6 @@ func (kb keyringKeybase) writeInfo(name string, info Info) {
}
}
//nolint: funlen
func lkbToKeyringConfig(name, dir string, buf io.Reader, test bool) keyring.Config {
if test {
return keyring.Config{

2
go.sum
View File

@ -237,8 +237,6 @@ github.com/tendermint/btcd v0.1.1/go.mod h1:DC6/m53jtQzr/NFmMNEu0rxf18/ktVoVtMrn
github.com/tendermint/crypto v0.0.0-20190823183015-45b1026d81ae h1:AOXNM7c2Vvo45SjAgeWF8Wy+NS7/NCqzRNpUc+HPAec=
github.com/tendermint/crypto v0.0.0-20190823183015-45b1026d81ae/go.mod h1:z4YtwM70uOnk8h0pjJYlj3zdYwi9l03By6iAIF5j/Pk=
github.com/tendermint/go-amino v0.14.1/go.mod h1:i/UKE5Uocn+argJJBb12qTZsCDBcAYMbR92AaJVmKso=
github.com/tendermint/go-amino v0.15.0 h1:TC4e66P59W7ML9+bxio17CPKnxW3nKIRAYskntMAoRk=
github.com/tendermint/go-amino v0.15.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME=
github.com/tendermint/go-amino v0.15.1 h1:D2uk35eT4iTsvJd9jWIetzthE5C0/k2QmMFkCN+4JgQ=
github.com/tendermint/go-amino v0.15.1/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME=
github.com/tendermint/iavl v0.12.4 h1:hd1woxUGISKkfUWBA4mmmTwOua6PQZTJM/F0FDrmMV8=

View File

@ -4,7 +4,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)
// nolint - reexport
const (
CodeOK = sdk.CodeOK
CodeInternal = sdk.CodeInternal
@ -14,10 +13,8 @@ const (
CodespaceRoot = sdk.CodespaceRoot
)
// nolint - reexport
type Error = sdk.Error
// nolint - reexport
func ErrInternal(msg string) Error {
return sdk.ErrInternal(msg)
}

View File

@ -307,14 +307,14 @@ func (st *Store) Query(req abci.RequestQuery) (res abci.ResponseQuery) {
// Implements types.Iterator.
type iavlIterator struct {
// Underlying store
tree *iavl.ImmutableTree
// Domain
start, end []byte
// Iteration order
ascending bool
key []byte // The current key (mutable)
value []byte // The current value (mutable)
// Underlying store
tree *iavl.ImmutableTree
// Channel to push iteration values.
iterCh chan cmn.KVPair
@ -325,13 +325,11 @@ type iavlIterator struct {
// Close this to signal that state is initialized.
initCh chan struct{}
//----------------------------------------
// What follows are mutable state.
mtx sync.Mutex
invalid bool // True once, true forever
key []byte // The current key
value []byte // The current value
ascending bool // Iteration order
invalid bool // True once, true forever (mutable)
}
var _ types.Iterator = (*iavlIterator)(nil)

View File

@ -169,7 +169,6 @@ func (tkv *Store) CacheWrapWithTrace(_ io.Writer, _ types.TraceContext) types.Ca
// writeOperation writes a KVStore operation to the underlying io.Writer as
// JSON-encoded data where the key/value pair is base64 encoded.
// nolint: errcheck
func writeOperation(w io.Writer, op operation, tc types.TraceContext, key, value []byte) {
traceOp := traceOperation{
Operation: op,

View File

@ -12,7 +12,6 @@ import (
// ExecuteT executes the command, pipes any input to STDIN and return STDOUT,
// logging STDOUT/STDERR to t.
// nolint: errcheck
func ExecuteT(t *testing.T, cmd, input string) (stdout, stderr string) {
t.Log("Running", cmd)

View File

@ -99,7 +99,7 @@ func waitForHeight(height int64, url string) {
for {
// Since this is in a testing file we are accepting nolint to be passed
res, err = http.Get(url) //nolint:gosec
res, err = http.Get(url) // nolint:gosec
if err != nil {
panic(err)
}
@ -151,7 +151,7 @@ func WaitForStart(url string) {
time.Sleep(time.Millisecond * 100)
var res *http.Response
res, err = http.Get(url) //nolint:gosec Error is arising in testing files, accepting nolint
res, err = http.Get(url) // nolint:gosec
if err != nil || res == nil {
continue
}

View File

@ -10,14 +10,14 @@ const DefaultKeyringServiceName = "cosmos"
// Config is the structure that holds the SDK configuration parameters.
// This could be used to initialize certain configuration parameters for the SDK.
type Config struct {
mtx sync.RWMutex
sealed bool
bech32AddressPrefix map[string]string
coinType uint32
fullFundraiserPath string
keyringServiceName string
bech32AddressPrefix map[string]string
txEncoder TxEncoder
addressVerifier func([]byte) error
keyringServiceName string
mtx sync.RWMutex
coinType uint32
sealed bool
}
// cosmos-sdk wide global singleton

View File

@ -91,7 +91,7 @@ func TestLogContext(t *testing.T) {
require.Equal(t, *logger.logs, []string{"debug", "info", "error"})
}
type dummy int64 //nolint: unused
type dummy int64 //nolint:unused
func (d dummy) Clone() interface{} {
return d

View File

@ -45,7 +45,6 @@ func precisionInt() *big.Int {
return new(big.Int).Set(precisionReuse)
}
// nolint - common values
func ZeroDec() Dec { return Dec{new(big.Int).Set(zeroInt)} }
func OneDec() Dec { return Dec{precisionInt()} }
func SmallestDec() Dec { return Dec{new(big.Int).Set(oneInt)} }
@ -394,7 +393,6 @@ func (d Dec) String() string {
// |_____: / | $$$ |
// |________|
// nolint - go-cyclo
// Remove a Precision amount of rightmost digits and perform bankers rounding
// on the remainder (gaussian rounding) on the digits which have been removed.
//

View File

@ -328,7 +328,7 @@ func AppendMsgToErr(msg string, err string) string {
}
// returns the index of the message in the ABCI Log
// nolint: deadcode unused
// nolint:deadcode,unused
func mustGetMsgIndex(abciLog string) int {
msgIdx := strings.Index(abciLog, "message\":\"")
if msgIdx == -1 {

View File

@ -37,7 +37,7 @@ $ <appcli> tx broadcast ./mytxn.json
}
res, err := cliCtx.BroadcastTx(txBytes)
cliCtx.PrintOutput(res) // nolint:errcheck
cliCtx.PrintOutput(res)
return err
},

View File

@ -12,11 +12,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth/exported"
)
var (
stakeDenom = "stake"
feeDenom = "fee"
)
func TestBaseAddressPubKey(t *testing.T) {
_, pub1, addr1 := KeyTestPubAddr()
_, pub2, addr2 := KeyTestPubAddr()

View File

@ -316,7 +316,6 @@ func (keeper BaseSendKeeper) SetCoins(ctx sdk.Context, addr sdk.AccAddress, amt
}
// GetSendEnabled returns the current SendEnabled
// nolint: errcheck
func (keeper BaseSendKeeper) GetSendEnabled(ctx sdk.Context) bool {
var enabled bool
keeper.paramSpace.Get(ctx, types.ParamStoreKeySendEnabled, &enabled)

View File

@ -6,7 +6,6 @@ import (
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519"
"github.com/tendermint/tendermint/libs/log"
dbm "github.com/tendermint/tm-db"
@ -23,7 +22,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/distribution/types"
)
//nolint: deadcode unused
//nolint:deadcode,unused
var (
delPk1 = ed25519.GenPrivKey().PubKey()
delPk2 = ed25519.GenPrivKey().PubKey()
@ -47,7 +46,6 @@ var (
valConsPk3 = ed25519.GenPrivKey().PubKey()
valConsAddr1 = sdk.ConsAddress(valConsPk1.Address())
valConsAddr2 = sdk.ConsAddress(valConsPk2.Address())
valConsAddr3 = sdk.ConsAddress(valConsPk3.Address())
// TODO move to common testing package for all modules
// test addresses
@ -56,10 +54,6 @@ var (
valAccAddr1, valAccAddr2, valAccAddr3,
}
emptyDelAddr sdk.AccAddress
emptyValAddr sdk.ValAddress
emptyPubkey crypto.PubKey
distrAcc = supply.NewEmptyModuleAccount(types.ModuleName)
)

View File

@ -7,7 +7,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)
// nolint: deadcode unused
// nolint:deadcode,unused,varcheck
var (
delPk1 = ed25519.GenPrivKey().PubKey()
delPk2 = ed25519.GenPrivKey().PubKey()

View File

@ -143,7 +143,6 @@ func (vo VoteOption) String() string {
}
// Format implements the fmt.Formatter interface.
// nolint: errcheck
func (vo VoteOption) Format(s fmt.State, verb rune) {
switch verb {
case 's':

View File

@ -110,7 +110,6 @@ func (app *App) CompleteSetup(newKeys ...sdk.StoreKey) error {
}
// InitChainer performs custom logic for initialization.
// nolint: errcheck
func (app *App) InitChainer(ctx sdk.Context, _ abci.RequestInitChain) abci.ResponseInitChain {
// Load the genesis accounts
@ -282,7 +281,6 @@ func GeneratePrivKeyAddressPairsFromRand(rand *rand.Rand, n int) (keys []crypto.
// RandomSetGenesis set genesis accounts with random coin values using the
// provided addresses and coin denominations.
// nolint: errcheck
func RandomSetGenesis(r *rand.Rand, app *App, addrs []sdk.AccAddress, denoms []string) {
accts := make([]authexported.Account, len(addrs))
randCoinIntervals := []BigInterval{

View File

@ -1,4 +1,4 @@
// nolint: deadcode unused
// nolint:deadcode,unused
package params
import (

View File

@ -1,4 +1,4 @@
// nolint:deadcode unused
// nolint:deadcode,unused
// DONTCOVER
// noalias
package keeper
@ -131,7 +131,7 @@ func newPubKey(pk string) (res crypto.PubKey) {
panic(err)
}
var pkEd ed25519.PubKeyEd25519
copy(pkEd[:], pkBytes[:])
copy(pkEd[:], pkBytes)
return pkEd
}

View File

@ -15,7 +15,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/slashing/internal/types"
)
// nolint:deadcode unused
// nolint:deadcode,unused,varcheck
var (
delPk1 = ed25519.GenPrivKey().PubKey()
delAddr1 = sdk.AccAddress(delPk1.Address())

View File

@ -28,7 +28,7 @@ import (
)
// dummy addresses used for testing
// nolint: unused deadcode
// nolint:unused, deadcode
var (
Addrs = createTestAddrs(500)
PKs = createTestPubKeys(500)
@ -282,7 +282,7 @@ func TestingUpdateValidator(keeper Keeper, ctx sdk.Context, validator types.Vali
return validator
}
// nolint: deadcode unused
// nolint:deadcode, unused
func validatorByPowerIndexExists(k Keeper, ctx sdk.Context, power []byte) bool {
store := ctx.KVStore(k.storeKey)
return store.Has(power)

View File

@ -9,7 +9,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/staking/types"
)
// nolint: deadcode unused
// nolint:deadcode,unused,varcheck
var (
priv1 = secp256k1.GenPrivKey()
addr1 = sdk.AccAddress(priv1.PubKey().Address())

View File

@ -394,7 +394,7 @@ func (d DelegationResponses) String() (out string) {
// responses.
type RedelegationResponse struct {
Redelegation
Entries []RedelegationEntryResponse `json:"entries" yaml:"entries"` // nolint: structtag
Entries []RedelegationEntryResponse `json:"entries" yaml:"entries"`
}
// RedelegationEntryResponse is equivalent to a RedelegationEntry except that it

View File

@ -7,7 +7,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)
// nolint: deadcode unused
// nolint:deadcode,unused
var (
pk1 = ed25519.GenPrivKey().PubKey()
pk2 = ed25519.GenPrivKey().PubKey()

View File

@ -15,7 +15,7 @@ var (
holder = "holder"
)
// nolint: deadcode unused
// nolint:deadcode,unused
func createTestApp(isCheckTx bool) (*simapp.SimApp, sdk.Context) {
app := simapp.Setup(isCheckTx)