Skip to content

Commit

Permalink
chore: fix linting issues exposed by fixing golangci-lint (#12895)
Browse files Browse the repository at this point in the history
Co-authored-by: Marko <marbar3778@yahoo.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>
  • Loading branch information
3 people authored Aug 11, 2022
1 parent 15b04c2 commit 0943a70
Show file tree
Hide file tree
Showing 148 changed files with 571 additions and 469 deletions.
2 changes: 1 addition & 1 deletion baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type (
)

// BaseApp reflects the ABCI application implementation.
type BaseApp struct { // nolint: maligned
type BaseApp struct { //nolint: maligned
// initialized on creation
logger log.Logger
name string // application name from abci.Info
Expand Down
6 changes: 3 additions & 3 deletions baseapp/msg_service_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ func (msr *MsgServiceRouter) HandlerByTypeURL(typeURL string) MsgServiceHandler
// service description, handler is an object which implements that gRPC service.
//
// This function PANICs:
// - if it is called before the service `Msg`s have been registered using
// RegisterInterfaces,
// - or if a service is being registered twice.
// - if it is called before the service `Msg`s have been registered using
// RegisterInterfaces,
// - or if a service is being registered twice.
func (msr *MsgServiceRouter) RegisterService(sd *grpc.ServiceDesc, handler interface{}) {
// Adds a top-level query handler based on the gRPC service name.
for _, method := range sd.Methods {
Expand Down
11 changes: 6 additions & 5 deletions client/keys/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,13 @@ func runAddCmdPrepare(cmd *cobra.Command, args []string) error {

/*
input
- bip39 mnemonic
- bip39 passphrase
- bip44 path
- local encryption password
- bip39 mnemonic
- bip39 passphrase
- bip44 path
- local encryption password
output
- armor encrypted private key (saved to file)
- armor encrypted private key (saved to file)
*/
func runAddCmd(ctx client.Context, cmd *cobra.Command, args []string, inBuf *bufio.Reader) error {
var err error
Expand Down
10 changes: 6 additions & 4 deletions codec/amino_codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ func (ac *AminoCodec) MarshalInterface(i proto.Message) ([]byte, error) {
// NOTE: to unmarshal a concrete type, you should use Unmarshal instead
//
// Example:
// var x MyInterface
// err := cdc.UnmarshalInterface(bz, &x)
//
// var x MyInterface
// err := cdc.UnmarshalInterface(bz, &x)
func (ac *AminoCodec) UnmarshalInterface(bz []byte, ptr interface{}) error {
return ac.LegacyAmino.Unmarshal(bz, ptr)
}
Expand All @@ -117,8 +118,9 @@ func (ac *AminoCodec) MarshalInterfaceJSON(i proto.Message) ([]byte, error) {
// NOTE: to unmarshal a concrete type, you should use UnmarshalJSON instead
//
// Example:
// var x MyInterface
// err := cdc.UnmarshalInterfaceJSON(bz, &x)
//
// var x MyInterface
// err := cdc.UnmarshalInterfaceJSON(bz, &x)
func (ac *AminoCodec) UnmarshalInterfaceJSON(bz []byte, ptr interface{}) error {
return ac.LegacyAmino.UnmarshalJSON(bz, ptr)
}
10 changes: 6 additions & 4 deletions codec/proto_codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,9 @@ func (pc *ProtoCodec) MarshalInterface(i gogoproto.Message) ([]byte, error) {
// NOTE: to unmarshal a concrete type, you should use Unmarshal instead
//
// Example:
// var x MyInterface
// err := cdc.UnmarshalInterface(bz, &x)
//
// var x MyInterface
// err := cdc.UnmarshalInterface(bz, &x)
func (pc *ProtoCodec) UnmarshalInterface(bz []byte, ptr interface{}) error {
any := &types.Any{}
err := pc.Unmarshal(bz, any)
Expand Down Expand Up @@ -233,8 +234,9 @@ func (pc *ProtoCodec) MarshalInterfaceJSON(x gogoproto.Message) ([]byte, error)
// NOTE: to unmarshal a concrete type, you should use UnmarshalJSON instead
//
// Example:
// var x MyInterface // must implement proto.Message
// err := cdc.UnmarshalInterfaceJSON(&x, bz)
//
// var x MyInterface // must implement proto.Message
// err := cdc.UnmarshalInterfaceJSON(&x, bz)
func (pc *ProtoCodec) UnmarshalInterfaceJSON(bz []byte, iface interface{}) error {
any := &types.Any{}
err := pc.UnmarshalJSON(bz, any)
Expand Down
12 changes: 6 additions & 6 deletions codec/unknownproto/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ b) Mismatched wire types for a field -- this is indicative of mismatched service
Its API signature is similar to proto.Unmarshal([]byte, proto.Message) in the strict case
if err := RejectUnknownFieldsStrict(protoBlob, protoMessage, false); err != nil {
// Handle the error.
}
if err := RejectUnknownFieldsStrict(protoBlob, protoMessage, false); err != nil {
// Handle the error.
}
and ideally should be added before invoking proto.Unmarshal, if you'd like to enforce the features mentioned above.
By default, for security we report every single field that's unknown, whether a non-critical field or not. To customize
this behavior, please set the boolean parameter allowUnknownNonCriticals to true to RejectUnknownFields:
if err := RejectUnknownFields(protoBlob, protoMessage, true); err != nil {
// Handle the error.
}
if err := RejectUnknownFields(protoBlob, protoMessage, true); err != nil {
// Handle the error.
}
*/
package unknownproto
2 changes: 1 addition & 1 deletion cosmovisor/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ func (cfg *Config) SetCurrentUpgrade(u upgradetypes.Plan) (rerr error) {
return err
}
_, err = f.Write(bz)
return err
return err
}

func (cfg *Config) UpgradeInfo() (upgradetypes.Plan, error) {
Expand Down
5 changes: 3 additions & 2 deletions cosmovisor/args_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ func (c *cosmovisorEnv) Set(envVar, envVal string) {

// clearEnv clears environment variables and what they were.
// Designed to be used like this:
// initialEnv := clearEnv()
// defer setEnv(nil, initialEnv)
//
// initialEnv := clearEnv()
// defer setEnv(nil, initialEnv)
func (s *argsTestSuite) clearEnv() *cosmovisorEnv {
s.T().Logf("Clearing environment variables.")
rv := cosmovisorEnv{}
Expand Down
5 changes: 3 additions & 2 deletions cosmovisor/cmd/cosmovisor/help_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ func (c *cosmovisorHelpEnv) Set(envVar, envVal string) {

// clearEnv clears environment variables and returns what they were.
// Designed to be used like this:
// initialEnv := clearEnv()
// defer setEnv(nil, initialEnv)
//
// initialEnv := clearEnv()
// defer setEnv(nil, initialEnv)
func (s *HelpTestSuite) clearEnv() *cosmovisorHelpEnv {
s.T().Logf("Clearing environment variables.")
rv := cosmovisorHelpEnv{}
Expand Down
10 changes: 6 additions & 4 deletions cosmovisor/cmd/cosmovisor/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ func (c *cosmovisorInitEnv) Set(envVar, envVal string) {

// clearEnv clears environment variables and returns what they were.
// Designed to be used like this:
// initialEnv := clearEnv()
// defer setEnv(nil, initialEnv)
//
// initialEnv := clearEnv()
// defer setEnv(nil, initialEnv)
func (s *InitTestSuite) clearEnv() *cosmovisorInitEnv {
s.T().Logf("Clearing environment variables.")
rv := cosmovisorInitEnv{}
Expand Down Expand Up @@ -137,8 +138,9 @@ func NewBufferedPipe(name string, replicateTo ...io.Writer) (BufferedPipe, error
// StartNewBufferedPipe creates a new BufferedPipe and starts it.
//
// This is functionally equivalent to:
// p, _ := NewBufferedPipe(name, replicateTo...)
// p.Start()
//
// p, _ := NewBufferedPipe(name, replicateTo...)
// p.Start()
func StartNewBufferedPipe(name string, replicateTo ...io.Writer) (BufferedPipe, error) {
p, err := NewBufferedPipe(name, replicateTo...)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions crypto/armor.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"bytes"
"encoding/hex"
"fmt"
"io/ioutil"
"io"

"github.com/tendermint/crypto/bcrypt"
"github.com/tendermint/tendermint/crypto"
"golang.org/x/crypto/openpgp/armor" // nolint: staticcheck
"golang.org/x/crypto/openpgp/armor" //nolint: staticcheck

"github.com/cosmos/cosmos-sdk/codec/legacy"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
Expand Down Expand Up @@ -235,7 +235,7 @@ func DecodeArmor(armorStr string) (blockType string, headers map[string]string,
if err != nil {
return "", nil, nil, err
}
data, err = ioutil.ReadAll(block.Body)
data, err = io.ReadAll(block.Body)
if err != nil {
return "", nil, nil, err
}
Expand Down
5 changes: 3 additions & 2 deletions crypto/hd/doc.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Package hd provides support for hierarchical deterministic wallets generation and derivation.
//
// The user must understand the overall concept of the BIP 32 and the BIP 44 specs:
// https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki
// https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki
//
// https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki
// https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki
//
// In combination with the bip39 package in go-crypto this package provides the functionality for
// deriving keys using a BIP 44 HD path, or, more general, by passing a BIP 32 path.
Expand Down
2 changes: 1 addition & 1 deletion crypto/hd/hdpath.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func DerivePrivateKeyForPath(privKeyBytes, chainCode [32]byte, path string) ([]b
// If harden is true, the derivation is 'hardened'.
// It returns the new private key and new chain code.
// For more information on hardened keys see:
// - https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki
// - https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki
func derivePrivateKey(privKeyBytes [32]byte, chainCode [32]byte, index uint32, harden bool) ([32]byte, [32]byte) {
var data []byte

Expand Down
40 changes: 20 additions & 20 deletions crypto/keyring/doc.go
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
// Package keys provides common key management API.
//
//
// The Keyring interface
// # The Keyring interface
//
// The Keyring interface defines the methods that a type needs to implement to be used
// as key storage backend. This package provides few implementations out-of-the-box.
//
// NewInMemory
// # NewInMemory
//
// The NewInMemory constructor returns an implementation backed by an in-memory, goroutine-safe
// map that has historically been used for testing purposes or on-the-fly key generation as the
// generated keys are discarded when the process terminates or the type instance is garbage
// collected.
//
// New
// # New
//
// The New constructor returns an implementation backed by a keyring library
// (https://github.com/99designs/keyring), whose aim is to provide a common abstraction and uniform
// interface between secret stores available for Windows, macOS, and most GNU/Linux distributions
// as well as operating system-agnostic encrypted file-based backends.
//
// The backends:
// os The instance returned by this constructor uses the operating system's default
// credentials store to handle keys storage operations securely. It should be noted
// that the keyring keyring may be kept unlocked for the whole duration of the user
// session.
// file This backend more closely resembles the previous keyring storage used prior to
// v0.38.1. It stores the keyring encrypted within the app's configuration directory.
// This keyring will request a password each time it is accessed, which may occur
// multiple times in a single command resulting in repeated password prompts.
// kwallet This backend uses KDE Wallet Manager as a credentials management application:
// https://github.com/KDE/kwallet
// pass This backend uses the pass command line utility to store and retrieve keys:
// https://www.passwordstore.org/
// test This backend stores keys insecurely to disk. It does not prompt for a password to
// be unlocked and it should be use only for testing purposes.
// memory Same instance as returned by NewInMemory. This backend uses a transient storage. Keys
// are discarded when the process terminates or the type instance is garbage collected.
//
// os The instance returned by this constructor uses the operating system's default
// credentials store to handle keys storage operations securely. It should be noted
// that the keyring keyring may be kept unlocked for the whole duration of the user
// session.
// file This backend more closely resembles the previous keyring storage used prior to
// v0.38.1. It stores the keyring encrypted within the app's configuration directory.
// This keyring will request a password each time it is accessed, which may occur
// multiple times in a single command resulting in repeated password prompts.
// kwallet This backend uses KDE Wallet Manager as a credentials management application:
// https://github.com/KDE/kwallet
// pass This backend uses the pass command line utility to store and retrieve keys:
// https://www.passwordstore.org/
// test This backend stores keys insecurely to disk. It does not prompt for a password to
// be unlocked and it should be use only for testing purposes.
// memory Same instance as returned by NewInMemory. This backend uses a transient storage. Keys
// are discarded when the process terminates or the type instance is garbage collected.
package keyring
2 changes: 1 addition & 1 deletion crypto/keyring/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type KeyOutput struct {
}

// NewKeyOutput creates a default KeyOutput instance without Mnemonic, Threshold and PubKeys
func NewKeyOutput(name string, keyType KeyType, a sdk.Address, pk cryptotypes.PubKey) (KeyOutput, error) { // nolint:interfacer
func NewKeyOutput(name string, keyType KeyType, a sdk.Address, pk cryptotypes.PubKey) (KeyOutput, error) { //nolint:interfacer
apk, err := codectypes.NewAnyWithValue(pk)
if err != nil {
return KeyOutput{}, err
Expand Down
3 changes: 1 addition & 2 deletions crypto/keys/multisig/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ const (
PubKeyAminoRoute = "tendermint/PubKeyMultisigThreshold"
)

//nolint
// Deprecated: Amino is being deprecated in the SDK. But even if you need to
// AminoCdc is being deprecated in the SDK. But even if you need to
// use Amino for some reason, please use `codec/legacy.Cdc` instead.
var AminoCdc = codec.NewLegacyAmino()

Expand Down
2 changes: 1 addition & 1 deletion crypto/keys/secp256k1/secp256k1.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

secp256k1 "github.com/btcsuite/btcd/btcec"
"github.com/tendermint/tendermint/crypto"
"golang.org/x/crypto/ripemd160" // nolint: staticcheck // necessary for Bitcoin address format
"golang.org/x/crypto/ripemd160" //nolint: staticcheck // necessary for Bitcoin address format

"github.com/cosmos/cosmos-sdk/codec"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
Expand Down
4 changes: 2 additions & 2 deletions crypto/keys/secp256k1/secp256k1_nocgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (

// used to reject malleable signatures
// see:
// - https://github.com/ethereum/go-ethereum/blob/f9401ae011ddf7f8d2d95020b7446c17f8d98dc1/crypto/signature_nocgo.go#L90-L93
// - https://github.com/ethereum/go-ethereum/blob/f9401ae011ddf7f8d2d95020b7446c17f8d98dc1/crypto/crypto.go#L39
// - https://github.com/ethereum/go-ethereum/blob/f9401ae011ddf7f8d2d95020b7446c17f8d98dc1/crypto/signature_nocgo.go#L90-L93
// - https://github.com/ethereum/go-ethereum/blob/f9401ae011ddf7f8d2d95020b7446c17f8d98dc1/crypto/crypto.go#L39
var secp256k1halfN = new(big.Int).Rsh(secp256k1.S256().N, 1)

// Sign creates an ECDSA signature on curve Secp256k1, using SHA256 on the msg.
Expand Down
18 changes: 9 additions & 9 deletions db/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,16 @@ type ReadWriter interface {
//
// Typical usage:
//
// var itr Iterator = ...
// defer itr.Close()
// var itr Iterator = ...
// defer itr.Close()
//
// for itr.Next() {
// k, v := itr.Key(); itr.Value()
// ...
// }
// if err := itr.Error(); err != nil {
// ...
// }
// for itr.Next() {
// k, v := itr.Key(); itr.Value()
// ...
// }
// if err := itr.Error(); err != nil {
// ...
// }
type Iterator interface {
// Domain returns the start (inclusive) and end (exclusive) limits of the iterator.
// CONTRACT: start, end readonly []byte
Expand Down
8 changes: 5 additions & 3 deletions depinject/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ func invoke(ctr *container, key *moduleKey, invokers []interface{}) error {
// instance when an interface of type Duck is requested as an input.
//
// BindInterface(
//
// "cosmossdk.io/depinject_test/depinject_test.Duck",
// "cosmossdk.io/depinject_test/depinject_test.Canvasback")
func BindInterface(inTypeName string, outTypeName string) Config {
Expand All @@ -106,9 +107,10 @@ func BindInterface(inTypeName string, outTypeName string) Config {
// "moduleFoo".
//
// BindInterfaceInModule(
// "moduleFoo",
// "cosmossdk.io/depinject_test/depinject_test.Duck",
// "cosmossdk.io/depinject_test/depinject_test.Canvasback")
//
// "moduleFoo",
// "cosmossdk.io/depinject_test/depinject_test.Duck",
// "cosmossdk.io/depinject_test/depinject_test.Canvasback")
func BindInterfaceInModule(moduleName string, inTypeName string, outTypeName string) Config {
return containerConfig(func(ctr *container) error {
return bindInterface(ctr, inTypeName, outTypeName, moduleName)
Expand Down
1 change: 0 additions & 1 deletion depinject/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,6 @@ func (c *container) build(loc Location, outputs ...interface{}) error {

if !values[i].CanInterface() {
return []reflect.Value{}, fmt.Errorf("depinject.Out struct %s on package can't have unexported field", values[i].String())

}
val.Elem().Set(values[i])
}
Expand Down
5 changes: 3 additions & 2 deletions depinject/inject.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ package depinject
// can be provided by the container.
//
// Ex:
// var x int
// Inject(Provide(func() int { return 1 }), &x)
//
// var x int
// Inject(Provide(func() int { return 1 }), &x)
//
// Inject uses the debug mode provided by AutoDebug which means there will be
// verbose debugging information if there is an error and nothing upon success.
Expand Down
3 changes: 2 additions & 1 deletion depinject/provider_desc.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import (
// ProviderDescriptor defines a special provider type that is defined by
// reflection. It should be passed as a value to the Provide function.
// Ex:
// option.Provide(ProviderDescriptor{ ... })
//
// option.Provide(ProviderDescriptor{ ... })
type ProviderDescriptor struct {
// Inputs defines the in parameter types to Fn.
Inputs []ProviderInput
Expand Down
Loading

0 comments on commit 0943a70

Please sign in to comment.