Skip to content

Commit

Permalink
style: more linting (#15618)
Browse files Browse the repository at this point in the history
  • Loading branch information
tac0turtle committed Mar 30, 2023
1 parent c1ea84d commit 51f3e70
Show file tree
Hide file tree
Showing 34 changed files with 68 additions and 82 deletions.
4 changes: 2 additions & 2 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ func (app *BaseApp) PrepareProposalVerifyTx(tx sdk.Tx) ([]byte, error) {
return nil, err
}

_, _, _, _, err = app.runTx(runTxPrepareProposal, bz) //nolint:dogsled
_, _, _, _, err = app.runTx(runTxPrepareProposal, bz)
if err != nil {
return nil, err
}
Expand All @@ -880,7 +880,7 @@ func (app *BaseApp) ProcessProposalVerifyTx(txBz []byte) (sdk.Tx, error) {
return nil, err
}

_, _, _, _, err = app.runTx(runTxProcessProposal, txBz) //nolint:dogsled
_, _, _, _, err = app.runTx(runTxProcessProposal, txBz)
if err != nil {
return nil, err
}
Expand Down
6 changes: 3 additions & 3 deletions client/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ const (
// initClientContext initiates client Context for tests
func initClientContext(t *testing.T, envVar string) (client.Context, func()) {
home := t.TempDir()
chainId := "test-chain" //nolint:revive
chainID := "test-chain"
clientCtx := client.Context{}.
WithHomeDir(home).
WithViper("").
WithCodec(codec.NewProtoCodec(codectypes.NewInterfaceRegistry())).
WithChainID(chainId)
WithChainID(chainID)

require.NoError(t, clientCtx.Viper.BindEnv(nodeEnv))
if envVar != "" {
Expand All @@ -38,7 +38,7 @@ func initClientContext(t *testing.T, envVar string) (client.Context, func()) {

clientCtx, err := config.ReadFromClientConfig(clientCtx)
require.NoError(t, err)
require.Equal(t, clientCtx.ChainID, chainId)
require.Equal(t, clientCtx.ChainID, chainID)

return clientCtx, func() { _ = os.RemoveAll(home) }
}
Expand Down
2 changes: 1 addition & 1 deletion client/keys/import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ HbP+c6JmeJy9JXe2rbbF1QtCX1gLqGcDQPBXiCtFvP7/8wTZtVOPj8vREzhZ9ElO
t.Cleanup(cleanupKeys(t, kb, "keyname1"))

keyfile := filepath.Join(kbHome, "key.asc")
require.NoError(t, os.WriteFile(keyfile, []byte(armoredKey), 0o644)) //nolint:gosec
require.NoError(t, os.WriteFile(keyfile, []byte(armoredKey), 0o600))

defer func() {
_ = os.RemoveAll(kbHome)
Expand Down
2 changes: 1 addition & 1 deletion client/keys/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 keyring.KeyType, a sdk.Address, pk cryptotypes.PubKey) (KeyOutput, error) { //nolint:interfacer
func NewKeyOutput(name string, keyType keyring.KeyType, a sdk.Address, pk cryptotypes.PubKey) (KeyOutput, error) {
apk, err := codectypes.NewAnyWithValue(pk)
if err != nil {
return KeyOutput{}, err
Expand Down
4 changes: 2 additions & 2 deletions codec/proto_codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func (pc *ProtoCodec) MustUnmarshalJSON(bz []byte, ptr gogoproto.Message) {
}
}

// MarshalInterface is a convenience function for proto marshalling interfaces. It packs
// MarshalInterface is a convenience function for proto marshaling interfaces. It packs
// the provided value, which must be an interface, in an Any and then marshals it to bytes.
// NOTE: to marshal a concrete type, you should use Marshal instead
func (pc *ProtoCodec) MarshalInterface(i gogoproto.Message) ([]byte, error) {
Expand Down Expand Up @@ -224,7 +224,7 @@ func (pc *ProtoCodec) UnmarshalInterface(bz []byte, ptr interface{}) error {
return pc.UnpackAny(any, ptr)
}

// MarshalInterfaceJSON is a convenience function for proto marshalling interfaces. It
// MarshalInterfaceJSON is a convenience function for proto marshaling interfaces. It
// packs the provided value in an Any and then marshals it to bytes.
// NOTE: to marshal a concrete type, you should use MarshalJSON instead
func (pc *ProtoCodec) MarshalInterfaceJSON(x gogoproto.Message) ([]byte, error) {
Expand Down
2 changes: 1 addition & 1 deletion crypto/codec/amino.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func RegisterCrypto(cdc *codec.LegacyAmino) {
cdc.RegisterInterface((*cryptotypes.PrivKey)(nil), nil)
cdc.RegisterConcrete(sr25519.PrivKey{},
sr25519.PrivKeyName, nil)
cdc.RegisterConcrete(&ed25519.PrivKey{}, //nolint:staticcheck
cdc.RegisterConcrete(&ed25519.PrivKey{},
ed25519.PrivKeyName, nil)
cdc.RegisterConcrete(&secp256k1.PrivKey{},
secp256k1.PrivKeyName, nil)
Expand Down
16 changes: 8 additions & 8 deletions crypto/keys/ed25519/ed25519.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ func (privKey *PrivKey) Type() string {
return keyType
}

// MarshalAmino overrides Amino binary marshalling.
// MarshalAmino overrides Amino binary marshaling.
func (privKey PrivKey) MarshalAmino() ([]byte, error) {
return privKey.Key, nil
}

// UnmarshalAmino overrides Amino binary marshalling.
// UnmarshalAmino overrides Amino binary marshaling.
func (privKey *PrivKey) UnmarshalAmino(bz []byte) error {
if len(bz) != PrivKeySize {
return fmt.Errorf("invalid privkey size")
Expand All @@ -109,14 +109,14 @@ func (privKey *PrivKey) UnmarshalAmino(bz []byte) error {
return nil
}

// MarshalAminoJSON overrides Amino JSON marshalling.
// MarshalAminoJSON overrides Amino JSON marshaling.
func (privKey PrivKey) MarshalAminoJSON() ([]byte, error) {
// When we marshal to Amino JSON, we don't marshal the "key" field itself,
// just its contents (i.e. the key bytes).
return privKey.MarshalAmino()
}

// UnmarshalAminoJSON overrides Amino JSON marshalling.
// UnmarshalAminoJSON overrides Amino JSON marshaling.
func (privKey *PrivKey) UnmarshalAminoJSON(bz []byte) error {
return privKey.UnmarshalAmino(bz)
}
Expand Down Expand Up @@ -203,12 +203,12 @@ func (pubKey *PubKey) Equals(other cryptotypes.PubKey) bool {
return subtle.ConstantTimeCompare(pubKey.Bytes(), other.Bytes()) == 1
}

// MarshalAmino overrides Amino binary marshalling.
// MarshalAmino overrides Amino binary marshaling.
func (pubKey PubKey) MarshalAmino() ([]byte, error) {
return pubKey.Key, nil
}

// UnmarshalAmino overrides Amino binary marshalling.
// UnmarshalAmino overrides Amino binary marshaling.
func (pubKey *PubKey) UnmarshalAmino(bz []byte) error {
if len(bz) != PubKeySize {
return errorsmod.Wrap(errors.ErrInvalidPubKey, "invalid pubkey size")
Expand All @@ -218,14 +218,14 @@ func (pubKey *PubKey) UnmarshalAmino(bz []byte) error {
return nil
}

// MarshalAminoJSON overrides Amino JSON marshalling.
// MarshalAminoJSON overrides Amino JSON marshaling.
func (pubKey PubKey) MarshalAminoJSON() ([]byte, error) {
// When we marshal to Amino JSON, we don't marshal the "key" field itself,
// just its contents (i.e. the key bytes).
return pubKey.MarshalAmino()
}

// UnmarshalAminoJSON overrides Amino JSON marshalling.
// UnmarshalAminoJSON overrides Amino JSON marshaling.
func (pubKey *PubKey) UnmarshalAminoJSON(bz []byte) error {
return pubKey.UnmarshalAmino(bz)
}
2 changes: 1 addition & 1 deletion crypto/keys/ed25519/keys.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions crypto/keys/secp256k1/secp256k1.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ func (privKey *PrivKey) Type() string {
return keyType
}

// MarshalAmino overrides Amino binary marshalling.
// MarshalAmino overrides Amino binary marshaling.
func (privKey PrivKey) MarshalAmino() ([]byte, error) {
return privKey.Key, nil
}

// UnmarshalAmino overrides Amino binary marshalling.
// UnmarshalAmino overrides Amino binary marshaling.
func (privKey *PrivKey) UnmarshalAmino(bz []byte) error {
if len(bz) != PrivKeySize {
return fmt.Errorf("invalid privkey size")
Expand All @@ -68,14 +68,14 @@ func (privKey *PrivKey) UnmarshalAmino(bz []byte) error {
return nil
}

// MarshalAminoJSON overrides Amino JSON marshalling.
// MarshalAminoJSON overrides Amino JSON marshaling.
func (privKey PrivKey) MarshalAminoJSON() ([]byte, error) {
// When we marshal to Amino JSON, we don't marshal the "key" field itself,
// just its contents (i.e. the key bytes).
return privKey.MarshalAmino()
}

// UnmarshalAminoJSON overrides Amino JSON marshalling.
// UnmarshalAminoJSON overrides Amino JSON marshaling.
func (privKey *PrivKey) UnmarshalAminoJSON(bz []byte) error {
return privKey.UnmarshalAmino(bz)
}
Expand Down Expand Up @@ -179,12 +179,12 @@ func (pubKey *PubKey) Equals(other cryptotypes.PubKey) bool {
return pubKey.Type() == other.Type() && bytes.Equal(pubKey.Bytes(), other.Bytes())
}

// MarshalAmino overrides Amino binary marshalling.
// MarshalAmino overrides Amino binary marshaling.
func (pubKey PubKey) MarshalAmino() ([]byte, error) {
return pubKey.Key, nil
}

// UnmarshalAmino overrides Amino binary marshalling.
// UnmarshalAmino overrides Amino binary marshaling.
func (pubKey *PubKey) UnmarshalAmino(bz []byte) error {
if len(bz) != PubKeySize {
return errorsmod.Wrap(errors.ErrInvalidPubKey, "invalid pubkey size")
Expand All @@ -194,14 +194,14 @@ func (pubKey *PubKey) UnmarshalAmino(bz []byte) error {
return nil
}

// MarshalAminoJSON overrides Amino JSON marshalling.
// MarshalAminoJSON overrides Amino JSON marshaling.
func (pubKey PubKey) MarshalAminoJSON() ([]byte, error) {
// When we marshal to Amino JSON, we don't marshal the "key" field itself,
// just its contents (i.e. the key bytes).
return pubKey.MarshalAmino()
}

// UnmarshalAminoJSON overrides Amino JSON marshalling.
// UnmarshalAminoJSON overrides Amino JSON marshaling.
func (pubKey *PubKey) UnmarshalAminoJSON(bz []byte) error {
return pubKey.UnmarshalAmino(bz)
}
2 changes: 1 addition & 1 deletion proto/cosmos/crypto/ed25519/keys.proto
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ message PubKey {
bytes key = 1 [(gogoproto.casttype) = "crypto/ed25519.PublicKey"];
}

// Deprecated: PrivKey defines a ed25519 private key.
// PrivKey defines a ed25519 private key.
// NOTE: ed25519 keys must not be used in SDK apps except in a tendermint validator context.
message PrivKey {
option (amino.name) = "tendermint/PrivKeyEd25519";
Expand Down
8 changes: 4 additions & 4 deletions server/grpc/gogoreflection/serverreflection.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,8 @@ func fileDescWithDependencies(fd *dpb.FileDescriptorProto, sentFileDescriptors m
}

// fileDescEncodingByFilename finds the file descriptor for given filename,
// finds all of its previously unsent transitive dependencies, does marshalling
// on them, and returns the marshalled result.
// finds all of its previously unsent transitive dependencies, does marshaling
// on them, and returns the marshaled result.
func (s *serverReflectionServer) fileDescEncodingByFilename(name string, sentFileDescriptors map[string]bool) ([][]byte, error) {
enc := getFileDescriptor(name)
if enc == nil {
Expand Down Expand Up @@ -324,7 +324,7 @@ func parseMetadata(meta interface{}) ([]byte, bool) {

// fileDescEncodingContainingSymbol finds the file descriptor containing the
// given symbol, finds all of its previously unsent transitive dependencies,
// does marshalling on them, and returns the marshalled result. The given symbol
// does marshaling on them, and returns the marshaled result. The given symbol
// can be a type, a service or a method.
func (s *serverReflectionServer) fileDescEncodingContainingSymbol(name string, sentFileDescriptors map[string]bool) ([][]byte, error) {
_, symbols := s.getSymbols()
Expand All @@ -349,7 +349,7 @@ func (s *serverReflectionServer) fileDescEncodingContainingSymbol(name string, s

// fileDescEncodingContainingExtension finds the file descriptor containing
// given extension, finds all of its previously unsent transitive dependencies,
// does marshalling on them, and returns the marshalled result.
// does marshaling on them, and returns the marshaled result.
func (s *serverReflectionServer) fileDescEncodingContainingExtension(typeName string, extNum int32, sentFileDescriptors map[string]bool) ([][]byte, error) {
st, err := typeForName(typeName)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion server/grpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func StartGRPCServer(ctx context.Context, logger log.Logger, cfg config.GRPCConf
// the server failed to start properly.
select {
case <-ctx.Done():
// The calling process cancelled or closed the provided context, so we must
// The calling process canceled or closed the provided context, so we must
// gracefully stop the gRPC server.
logger.Info("stopping gRPC server...", "address", cfg.Address)
grpcSrv.GracefulStop()
Expand Down
2 changes: 1 addition & 1 deletion server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func startStandAlone(svrCtx *Context, appCreator types.AppCreator) error {
return err
}

// Wait for the calling process to be cancelled or close the provided context,
// Wait for the calling process to be canceled or close the provided context,
// so we can gracefully stop the ABCI server.
<-ctx.Done()
svrCtx.Logger.Info("stopping the ABCI server...")
Expand Down
2 changes: 1 addition & 1 deletion testutil/network/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func writeFile(name, dir string, contents []byte) error {
return fmt.Errorf("could not create directory %q: %w", dir, err)
}

if err := os.WriteFile(file, contents, 0o644); err != nil { //nolint: gosec
if err := os.WriteFile(file, contents, 0o600); err != nil {
return err
}

Expand Down
1 change: 0 additions & 1 deletion tools/cosmovisor/args_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,6 @@ func (s *argsTestSuite) TestGetConfigFromEnv() {
}
assert.Equal(t, tc.expectedErrCount, errCount, "error count")
}

assert.Equal(t, tc.expectedCfg, cfg, "config")
})
}
Expand Down
4 changes: 2 additions & 2 deletions types/query/collections_pagination.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type Collection[K, V any] interface {
KeyCodec() collcodec.KeyCodec[K]
}

// CollectionPaginate follows the same behaviour as Paginate but works on a Collection.
// CollectionPaginate follows the same behavior as Paginate but works on a Collection.
func CollectionPaginate[K, V any, C Collection[K, V]](
ctx context.Context,
coll C,
Expand Down Expand Up @@ -87,7 +87,7 @@ func CollectionFilteredPaginate[K, V any, C Collection[K, V]](
} else {
results, pageRes, err = collFilteredPaginateNoKey(ctx, coll, prefix, reverse, offset, limit, countTotal, predicateFunc)
}
// invalid iter error is ignored to retain Paginate behaviour
// invalid iter error is ignored to retain Paginate behavior
if errors.Is(err, collections.ErrInvalidIterator) {
return results, pageRes, nil
}
Expand Down
2 changes: 1 addition & 1 deletion x/auth/ante/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func TestRecoverPanic(t *testing.T) {
require.Equal(t, gasLimit, newCtx.GasMeter().Limit())

antehandler = sdk.ChainAnteDecorators(sud, PanicDecorator{})
require.Panics(t, func() { antehandler(suite.ctx, tx, false) }, "Recovered from non-Out-of-Gas panic") //nolint:errcheck
require.Panics(t, func() { antehandler(suite.ctx, tx, false) }, "Recovered from non-Out-of-Gas panic")
}

type OutOfGasDecorator struct{}
Expand Down
10 changes: 4 additions & 6 deletions x/auth/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,7 @@ func ProvideAddressCodec(config *modulev1.Module) address.Codec {
return codecaddress.NewBech32Codec(config.Bech32Prefix)
}

//nolint:revive
type AuthInputs struct {
type ModuleInputs struct {
depinject.In

Config *modulev1.Module
Expand All @@ -225,15 +224,14 @@ type AuthInputs struct {
LegacySubspace exported.Subspace `optional:"true"`
}

//nolint:revive
type AuthOutputs struct {
type ModuleOutputs struct {
depinject.Out

AccountKeeper keeper.AccountKeeper
Module appmodule.AppModule
}

func ProvideModule(in AuthInputs) AuthOutputs {
func ProvideModule(in ModuleInputs) ModuleOutputs {
maccPerms := map[string][]string{}
for _, permission := range in.Config.ModuleAccountPermissions {
maccPerms[permission.Account] = permission.Permissions
Expand All @@ -256,5 +254,5 @@ func ProvideModule(in AuthInputs) AuthOutputs {
k := keeper.NewAccountKeeper(in.Cdc, in.StoreService, in.AccountI, maccPerms, in.Config.Bech32Prefix, authority.String())
m := NewAppModule(in.Cdc, k, in.RandomGenesisAccountsFn, in.LegacySubspace)

return AuthOutputs{AccountKeeper: k, Module: m}
return ModuleOutputs{AccountKeeper: k, Module: m}
}
12 changes: 5 additions & 7 deletions x/auth/tx/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ func init() {
)
}

//nolint:revive
type TxInputs struct {
type ModuleInputs struct {
depinject.In

Config *txconfigv1.Config
Expand All @@ -41,15 +40,14 @@ type TxInputs struct {
CustomSignModeHandlers func() []signing.SignModeHandler `optional:"true"`
}

//nolint:revive
type TxOutputs struct {
type ModuleOutputs struct {
depinject.Out

TxConfig client.TxConfig
BaseAppOption runtime.BaseAppOption
}

func ProvideModule(in TxInputs) TxOutputs {
func ProvideModule(in ModuleInputs) ModuleOutputs {
textual, err := NewTextualWithBankKeeper(in.TxBankKeeper)
if err != nil {
panic(err)
Expand Down Expand Up @@ -100,10 +98,10 @@ func ProvideModule(in TxInputs) TxOutputs {
app.SetTxEncoder(txConfig.TxEncoder())
}

return TxOutputs{TxConfig: txConfig, BaseAppOption: baseAppOption}
return ModuleOutputs{TxConfig: txConfig, BaseAppOption: baseAppOption}
}

func newAnteHandler(txConfig client.TxConfig, in TxInputs) (sdk.AnteHandler, error) {
func newAnteHandler(txConfig client.TxConfig, in ModuleInputs) (sdk.AnteHandler, error) {
if in.BankKeeper == nil {
return nil, fmt.Errorf("both AccountKeeper and BankKeeper are required")
}
Expand Down
Loading

0 comments on commit 51f3e70

Please sign in to comment.