From 370acbb659fa7eeff467f0c7de38c7f525d78030 Mon Sep 17 00:00:00 2001 From: Facundo Medica <14063057+facundomedica@users.noreply.github.com> Date: Wed, 22 Mar 2023 17:20:46 -0300 Subject: [PATCH] style: gofumpt everything (#15518) --- client/v2/autocli/app.go | 4 ++- client/v2/autocli/common_test.go | 6 ++--- client/v2/autocli/flag/address.go | 2 +- client/v2/autocli/flag/builder.go | 1 - client/v2/autocli/msg.go | 1 - client/v2/autocli/msg_test.go | 7 ++--- client/v2/autocli/query_test.go | 2 -- client/v2/autocli/util.go | 3 ++- simapp/app.go | 3 ++- simapp/sim_bench_test.go | 3 ++- store/streaming/abci/examples/file/file.go | 2 +- store/streaming/streaming_test.go | 7 ++--- tests/integration/aminojson/aminojson_test.go | 27 ++++++++++++------- tests/integration/bank/keeper/keeper_test.go | 1 - tools/hubl/internal/remote.go | 3 ++- x/tx/signing/aminojson/encoder.go | 1 - x/tx/signing/aminojson/json_marshal_test.go | 1 - x/tx/signing/aminojson/time.go | 3 ++- x/tx/signing/direct_aux/direct_aux.go | 4 +-- x/tx/signing/get_signers_test.go | 1 - 20 files changed, 44 insertions(+), 38 deletions(-) diff --git a/client/v2/autocli/app.go b/client/v2/autocli/app.go index 32f22afcaec3..d42838765f84 100644 --- a/client/v2/autocli/app.go +++ b/client/v2/autocli/app.go @@ -1,10 +1,12 @@ package autocli import ( + "fmt" + autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" "cosmossdk.io/core/appmodule" "cosmossdk.io/depinject" - "fmt" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/spf13/cobra" diff --git a/client/v2/autocli/common_test.go b/client/v2/autocli/common_test.go index b7f8d6507474..a625d3068e57 100644 --- a/client/v2/autocli/common_test.go +++ b/client/v2/autocli/common_test.go @@ -3,6 +3,9 @@ package autocli import ( "bytes" "context" + "net" + "testing" + reflectionv2alpha1 "cosmossdk.io/api/cosmos/base/reflection/v2alpha1" "cosmossdk.io/client/v2/autocli/flag" "cosmossdk.io/client/v2/internal/testpb" @@ -12,8 +15,6 @@ import ( "gotest.tools/v3/assert" "google.golang.org/grpc/credentials/insecure" - "net" - "testing" ) func testExecCommon(t *testing.T, buildModuleCommand func(string, *Builder) (*cobra.Command, error), args ...string) *testClientConn { @@ -46,7 +47,6 @@ func testExecCommon(t *testing.T, buildModuleCommand func(string, *Builder) (*co } b := &Builder{ Builder: flag.Builder{ - GetClientConn: func() (grpc.ClientConnInterface, error) { return conn, nil }}, diff --git a/client/v2/autocli/flag/address.go b/client/v2/autocli/flag/address.go index 078aec467d85..16d6ce5759c2 100644 --- a/client/v2/autocli/flag/address.go +++ b/client/v2/autocli/flag/address.go @@ -2,6 +2,7 @@ package flag import ( "context" + reflectionv2alpha1 "cosmossdk.io/api/cosmos/base/reflection/v2alpha1" "github.com/cosmos/cosmos-sdk/types" "google.golang.org/protobuf/reflect/protoreflect" @@ -10,7 +11,6 @@ import ( type addressStringType struct{} func (a addressStringType) NewValue(ctx context.Context, b *Builder) Value { - if b.AddressPrefix == "" { conn, err := b.GetClientConn() if err != nil { diff --git a/client/v2/autocli/flag/builder.go b/client/v2/autocli/flag/builder.go index d42746fe3b1a..31c2389a6fc6 100644 --- a/client/v2/autocli/flag/builder.go +++ b/client/v2/autocli/flag/builder.go @@ -40,7 +40,6 @@ func (b *Builder) init() { b.scalarFlagTypes = map[string]Type{} b.scalarFlagTypes["cosmos.AddressString"] = addressStringType{} } - } func (b *Builder) DefineMessageFlagType(messageName protoreflect.FullName, flagType Type) { diff --git a/client/v2/autocli/msg.go b/client/v2/autocli/msg.go index fa33be66c106..14b5e8113be6 100644 --- a/client/v2/autocli/msg.go +++ b/client/v2/autocli/msg.go @@ -73,7 +73,6 @@ func (b *Builder) AddMsgServiceCommands(cmd *cobra.Command, cmdDescriptor *autoc // validate that methods exist if m := methods.ByName(methodName); m == nil { return fmt.Errorf("rpc method %q not found for service %q", methodName, service.FullName()) - } rpcOptMap[methodName] = option diff --git a/client/v2/autocli/msg_test.go b/client/v2/autocli/msg_test.go index e3628c80f2dc..b46c11974c16 100644 --- a/client/v2/autocli/msg_test.go +++ b/client/v2/autocli/msg_test.go @@ -2,10 +2,11 @@ package autocli import ( "fmt" - "google.golang.org/protobuf/encoding/protojson" "strings" "testing" + "google.golang.org/protobuf/encoding/protojson" + "gotest.tools/v3/golden" autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" @@ -127,7 +128,6 @@ func TestMsgOutputFormat(t *testing.T) { ) assert.Assert(t, strings.Contains(conn.out.String(), "positional1: 5")) - } func TestMsgOptionsError(t *testing.T) { @@ -145,7 +145,6 @@ func TestMsgOptionsError(t *testing.T) { "--u64", "abc", ) assert.Assert(t, strings.Contains(conn.errorOut.String(), "invalid argument ")) - } func TestDeprecatedMsg(t *testing.T) { @@ -325,7 +324,6 @@ func TestNotFoundErrorsMsg(t *testing.T) { }, }) assert.ErrorContains(t, err, "can't find field un-existent-flag") - } func TestEnhanceMessageCommand(t *testing.T) { @@ -368,7 +366,6 @@ func TestEnhanceMessageCommand(t *testing.T) { customCommands = map[string]*cobra.Command{} err = b.enhanceCommandCommon(cmd, options, customCommands, enhanceMsg) assert.NilError(t, err) - } type testMessageServer struct { diff --git a/client/v2/autocli/query_test.go b/client/v2/autocli/query_test.go index 4b1009c300f3..ab8c863cc0a0 100644 --- a/client/v2/autocli/query_test.go +++ b/client/v2/autocli/query_test.go @@ -18,7 +18,6 @@ import ( ) var buildModuleQueryCommand = func(moduleName string, b *Builder) (*cobra.Command, error) { - cmd := topLevelCmd(moduleName, fmt.Sprintf("Querying commands for the %s module", moduleName)) err := b.AddQueryServiceCommands(cmd, testCmdDesc) @@ -194,7 +193,6 @@ func TestOutputFormat(t *testing.T) { ) fmt.Println(conn.out.String()) assert.Assert(t, strings.Contains(conn.out.String(), " positional1: 1")) - } func TestHelp(t *testing.T) { diff --git a/client/v2/autocli/util.go b/client/v2/autocli/util.go index 198007b9af22..8ca8c39a0fa3 100644 --- a/client/v2/autocli/util.go +++ b/client/v2/autocli/util.go @@ -1,9 +1,10 @@ package autocli import ( - "google.golang.org/protobuf/reflect/protoreflect" "strings" + "google.golang.org/protobuf/reflect/protoreflect" + "cosmossdk.io/client/v2/internal/strcase" "github.com/spf13/cobra" ) diff --git a/simapp/app.go b/simapp/app.go index 1f6447054ce4..74ba81ee18a0 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -433,7 +433,8 @@ func NewSimApp( // NOTE: The genutils module must occur after staking so that pools are // properly initialized with tokens from genesis accounts. // NOTE: The genutils module must also occur after auth so that it can access the params from auth. - genesisModuleOrder := []string{authtypes.ModuleName, banktypes.ModuleName, + genesisModuleOrder := []string{ + authtypes.ModuleName, banktypes.ModuleName, distrtypes.ModuleName, stakingtypes.ModuleName, slashingtypes.ModuleName, govtypes.ModuleName, minttypes.ModuleName, crisistypes.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName, feegrant.ModuleName, nft.ModuleName, group.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName, diff --git a/simapp/sim_bench_test.go b/simapp/sim_bench_test.go index 1f0baf4e29c7..124369ea33cb 100644 --- a/simapp/sim_bench_test.go +++ b/simapp/sim_bench_test.go @@ -2,10 +2,11 @@ package simapp import ( "fmt" - "github.com/spf13/viper" "os" "testing" + "github.com/spf13/viper" + cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" flag "github.com/spf13/pflag" "github.com/stretchr/testify/require" diff --git a/store/streaming/abci/examples/file/file.go b/store/streaming/abci/examples/file/file.go index a0fa5dc138a0..7be160aa2e8a 100644 --- a/store/streaming/abci/examples/file/file.go +++ b/store/streaming/abci/examples/file/file.go @@ -26,7 +26,7 @@ func (a *FilePlugin) writeToFile(file string, data []byte) error { } filename := fmt.Sprintf("%s/%s.txt", home, file) - f, err := os.OpenFile(filepath.Clean(filename), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0600) + f, err := os.OpenFile(filepath.Clean(filename), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0o600) if err != nil { return err } diff --git a/store/streaming/streaming_test.go b/store/streaming/streaming_test.go index 14cc028e5d7c..5aee4fab26c0 100644 --- a/store/streaming/streaming_test.go +++ b/store/streaming/streaming_test.go @@ -118,7 +118,6 @@ func TestPluginTestSuite(t *testing.T) { func (s *PluginTestSuite) TestABCIGRPCPlugin() { s.T().Run("Should successfully load streaming", func(t *testing.T) { - abciListeners := s.loggerCtx.StreamingManager().ABCIListeners for _, abciListener := range abciListeners { for i := range [50]int{} { @@ -148,8 +147,10 @@ func (s *PluginTestSuite) updateHeight(n int64) { s.loggerCtx = NewMockContext(header, s.loggerCtx.Logger(), s.loggerCtx.StreamingManager()) } -var _ context.Context = MockContext{} -var _ storetypes.Context = MockContext{} +var ( + _ context.Context = MockContext{} + _ storetypes.Context = MockContext{} +) type MockContext struct { baseCtx context.Context diff --git a/tests/integration/aminojson/aminojson_test.go b/tests/integration/aminojson/aminojson_test.go index 0a2abe15f3a0..093bf68edabd 100644 --- a/tests/integration/aminojson/aminojson_test.go +++ b/tests/integration/aminojson/aminojson_test.go @@ -415,9 +415,11 @@ func TestAminoJSON_LegacyParity(t *testing.T) { "auth/params": {gogo: &authtypes.Params{TxSigLimit: 10}, pulsar: &authapi.Params{TxSigLimit: 10}}, "auth/module_account": { gogo: &authtypes.ModuleAccount{ - BaseAccount: authtypes.NewBaseAccountWithAddress(addr1), Permissions: []string{}}, + BaseAccount: authtypes.NewBaseAccountWithAddress(addr1), Permissions: []string{}, + }, pulsar: &authapi.ModuleAccount{ - BaseAccount: &authapi.BaseAccount{Address: addr1.String()}, Permissions: []string{}}, + BaseAccount: &authapi.BaseAccount{Address: addr1.String()}, Permissions: []string{}, + }, roundTripUnequal: true, }, "auth/base_account": { @@ -426,9 +428,11 @@ func TestAminoJSON_LegacyParity(t *testing.T) { }, "authz/msg_grant": { gogo: &authztypes.MsgGrant{ - Grant: authztypes.Grant{Expiration: &now, Authorization: genericAuth}}, + Grant: authztypes.Grant{Expiration: &now, Authorization: genericAuth}, + }, pulsar: &authzapi.MsgGrant{ - Grant: &authzapi.Grant{Expiration: timestamppb.New(now), Authorization: genericAuthPulsar}}, + Grant: &authzapi.Grant{Expiration: timestamppb.New(now), Authorization: genericAuthPulsar}, + }, }, "authz/msg_update_params": { gogo: &authtypes.MsgUpdateParams{Params: authtypes.Params{TxSigLimit: 10}}, @@ -482,12 +486,14 @@ func TestAminoJSON_LegacyParity(t *testing.T) { "consensus/evidence_params/big_duration": { gogo: &gov_v1beta1_types.VotingParams{VotingPeriod: time.Duration(rapidproto.MaxDurationSeconds*1e9) + 999999999}, pulsar: &gov_v1beta1_api.VotingParams{VotingPeriod: &durationpb.Duration{ - Seconds: rapidproto.MaxDurationSeconds, Nanos: 999999999}}, + Seconds: rapidproto.MaxDurationSeconds, Nanos: 999999999, + }}, }, "consensus/evidence_params/too_big_duration": { gogo: &gov_v1beta1_types.VotingParams{VotingPeriod: time.Duration(rapidproto.MaxDurationSeconds*1e9) + 999999999}, pulsar: &gov_v1beta1_api.VotingParams{VotingPeriod: &durationpb.Duration{ - Seconds: rapidproto.MaxDurationSeconds + 1, Nanos: 999999999}}, + Seconds: rapidproto.MaxDurationSeconds + 1, Nanos: 999999999, + }}, pulsarMarshalFails: true, }, // amino.dont_omitempty + empty/nil lists produce some surprising results @@ -521,7 +527,8 @@ func TestAminoJSON_LegacyParity(t *testing.T) { "slashing/params/dec": { gogo: &slashingtypes.Params{ DowntimeJailDuration: 1e9 + 7, - MinSignedPerWindow: types.NewDec(10)}, + MinSignedPerWindow: types.NewDec(10), + }, pulsar: &slashingapi.Params{ DowntimeJailDuration: &durationpb.Duration{Seconds: 1, Nanos: 7}, MinSignedPerWindow: dec10bz, @@ -548,11 +555,13 @@ func TestAminoJSON_LegacyParity(t *testing.T) { gogo: &stakingtypes.StakeAuthorization{ Validators: &stakingtypes.StakeAuthorization_AllowList{ AllowList: &stakingtypes.StakeAuthorization_Validators{Address: []string{"foo"}}, - }}, + }, + }, pulsar: &stakingapi.StakeAuthorization{ Validators: &stakingapi.StakeAuthorization_AllowList{ AllowList: &stakingapi.StakeAuthorization_Validators{Address: []string{"foo"}}, - }}, + }, + }, }, "vesting/base_account_empty": { gogo: &vestingtypes.BaseVestingAccount{BaseAccount: &authtypes.BaseAccount{}}, diff --git a/tests/integration/bank/keeper/keeper_test.go b/tests/integration/bank/keeper/keeper_test.go index c425317a7c60..cfbc59072959 100644 --- a/tests/integration/bank/keeper/keeper_test.go +++ b/tests/integration/bank/keeper/keeper_test.go @@ -474,7 +474,6 @@ func TestInputOutputCoins(t *testing.T) { assert.NilError(t, banktestutil.FundAccount(f.bankKeeper, ctx, addr1, balances)) insufficientInput := types.Input{ - Address: addr1.String(), Coins: sdk.NewCoins(newFooCoin(300), newBarCoin(100)), } diff --git a/tools/hubl/internal/remote.go b/tools/hubl/internal/remote.go index f1961a05d197..84b4f39f60f2 100644 --- a/tools/hubl/internal/remote.go +++ b/tools/hubl/internal/remote.go @@ -95,7 +95,8 @@ func RemoteCommand(config *Config, configDir string) ([]*cobra.Command, error) { FileResolver: chainInfo.ProtoFiles, GetClientConn: func() (grpc.ClientConnInterface, error) { return chainInfo.OpenClient() - }}, + }, + }, GetClientConn: func(command *cobra.Command) (grpc.ClientConnInterface, error) { return chainInfo.OpenClient() }, diff --git a/x/tx/signing/aminojson/encoder.go b/x/tx/signing/aminojson/encoder.go index 8fab6aba62e1..acb899edbd61 100644 --- a/x/tx/signing/aminojson/encoder.go +++ b/x/tx/signing/aminojson/encoder.go @@ -99,7 +99,6 @@ func keyFieldEncoder(_ *Encoder, msg protoreflect.Message, w io.Writer) error { _, err := fmt.Fprintf(w, `"%s"`, base64.StdEncoding.EncodeToString(bz)) return err - } type moduleAccountPretty struct { diff --git a/x/tx/signing/aminojson/json_marshal_test.go b/x/tx/signing/aminojson/json_marshal_test.go index e6b23d85ef6d..c86c2173a2d0 100644 --- a/x/tx/signing/aminojson/json_marshal_test.go +++ b/x/tx/signing/aminojson/json_marshal_test.go @@ -26,7 +26,6 @@ func marshalLegacy(msg proto.Message) ([]byte, error) { } func TestAminoJSON_EdgeCases(t *testing.T) { - cdc := amino.NewCodec() cdc.RegisterConcrete(&testpb.ABitOfEverything{}, "ABitOfEverything", nil) cdc.RegisterConcrete(&testpb.NestedMessage{}, "NestedMessage", nil) diff --git a/x/tx/signing/aminojson/time.go b/x/tx/signing/aminojson/time.go index c141de0eff4c..aa0ca9c84f5c 100644 --- a/x/tx/signing/aminojson/time.go +++ b/x/tx/signing/aminojson/time.go @@ -2,10 +2,11 @@ package aminojson import ( "fmt" - "google.golang.org/protobuf/reflect/protoreflect" "io" "math" "time" + + "google.golang.org/protobuf/reflect/protoreflect" ) const ( diff --git a/x/tx/signing/direct_aux/direct_aux.go b/x/tx/signing/direct_aux/direct_aux.go index c9ef9d864030..7af3fc01ae07 100644 --- a/x/tx/signing/direct_aux/direct_aux.go +++ b/x/tx/signing/direct_aux/direct_aux.go @@ -88,8 +88,8 @@ func (h SignModeHandler) getFirstSigner(txData signing.TxData) (string, error) { // GetSignBytes implements signing.SignModeHandler.GetSignBytes. func (h SignModeHandler) GetSignBytes( - _ context.Context, signerData signing.SignerData, txData signing.TxData) ([]byte, error) { - + _ context.Context, signerData signing.SignerData, txData signing.TxData, +) ([]byte, error) { feePayer := txData.AuthInfo.Fee.Payer if feePayer == "" { fp, err := h.getFirstSigner(txData) diff --git a/x/tx/signing/get_signers_test.go b/x/tx/signing/get_signers_test.go index 53b03f8a9775..f52fe54542aa 100644 --- a/x/tx/signing/get_signers_test.go +++ b/x/tx/signing/get_signers_test.go @@ -108,7 +108,6 @@ func TestGetSigners(t *testing.T) { require.NoError(t, err) } require.Equal(t, test.want, signers) - }) } }