From 778883418e1028c4ebc54952543a2e8c8bd4dd06 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Mon, 12 Feb 2024 10:24:06 +0100 Subject: [PATCH] fix(templates): fix lint errors in scaffolded chain (#3958) --- .../templates/app/files/app/export.go.plush | 24 +++++++++++++------ .../{{binaryNamePrefix}}d/cmd/root.go.plush | 2 +- ignite/templates/app/files/docs/docs.go.plush | 2 +- .../testutil/keeper/{{moduleName}}.go.plush | 4 +++- .../x/{{moduleName}}/module/genesis.go.plush | 4 +++- .../{{moduleName}}/module/simulation.go.plush | 5 ---- .../testutil/keeper/{{moduleName}}.go.plush | 4 +++- 7 files changed, 28 insertions(+), 17 deletions(-) diff --git a/ignite/templates/app/files/app/export.go.plush b/ignite/templates/app/files/app/export.go.plush index 94d498b703..c543f5b80b 100644 --- a/ignite/templates/app/files/app/export.go.plush +++ b/ignite/templates/app/files/app/export.go.plush @@ -167,7 +167,7 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str /* Handle staking state. */ // iterate through redelegations, reset creation height - app.StakingKeeper.IterateRedelegations(ctx, func(_ int64, red stakingtypes.Redelegation) (stop bool) { + err = app.StakingKeeper.IterateRedelegations(ctx, func(_ int64, red stakingtypes.Redelegation) (stop bool) { for i := range red.Entries { red.Entries[i].CreationHeight = 0 } @@ -177,9 +177,12 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str } return false }) - + if err != nil { + panic(err) + } + // iterate through unbonding delegations, reset creation height - app.StakingKeeper.IterateUnbondingDelegations(ctx, func(_ int64, ubd stakingtypes.UnbondingDelegation) (stop bool) { + err = app.StakingKeeper.IterateUnbondingDelegations(ctx, func(_ int64, ubd stakingtypes.UnbondingDelegation) (stop bool) { for i := range ubd.Entries { ubd.Entries[i].CreationHeight = 0 } @@ -189,6 +192,9 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str } return false }) + if err != nil { + panic(err) + } // Iterate through validators by power descending, reset bond heights, and // update bond intra-tx counters. @@ -208,7 +214,9 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str validator.Jailed = true } - app.StakingKeeper.SetValidator(ctx, validator) + if err := app.StakingKeeper.SetValidator(ctx, validator); err != nil { + panic(err) + } counter++ } @@ -226,13 +234,15 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str /* Handle slashing state. */ // reset start height on signing infos - app.SlashingKeeper.IterateValidatorSigningInfos( + if err := app.SlashingKeeper.IterateValidatorSigningInfos( ctx, func(addr sdk.ConsAddress, info slashingtypes.ValidatorSigningInfo) (stop bool) { info.StartHeight = 0 - app.SlashingKeeper.SetValidatorSigningInfo(ctx, addr, info) + _ = app.SlashingKeeper.SetValidatorSigningInfo(ctx, addr, info) return false }, - ) + ); err != nil { + log.Fatal(err) + } <% } %> } diff --git a/ignite/templates/app/files/cmd/{{binaryNamePrefix}}d/cmd/root.go.plush b/ignite/templates/app/files/cmd/{{binaryNamePrefix}}d/cmd/root.go.plush index 42e4490bb9..46122b9c13 100644 --- a/ignite/templates/app/files/cmd/{{binaryNamePrefix}}d/cmd/root.go.plush +++ b/ignite/templates/app/files/cmd/{{binaryNamePrefix}}d/cmd/root.go.plush @@ -132,7 +132,7 @@ func overwriteFlagDefaults(c *cobra.Command, defaults map[string]string) { set := func(s *pflag.FlagSet, key, val string) { if f := s.Lookup(key); f != nil { f.DefValue = val - f.Value.Set(val) + _ = f.Value.Set(val) } } for key, val := range defaults { diff --git a/ignite/templates/app/files/docs/docs.go.plush b/ignite/templates/app/files/docs/docs.go.plush index 152c6cab71..cac38a1399 100644 --- a/ignite/templates/app/files/docs/docs.go.plush +++ b/ignite/templates/app/files/docs/docs.go.plush @@ -30,7 +30,7 @@ func handler(title string) http.HandlerFunc { t, _ := httptemplate.ParseFS(template, indexFile) return func(w http.ResponseWriter, req *http.Request) { - t.Execute(w, struct { + _ = t.Execute(w, struct { Title string URL string }{ diff --git a/ignite/templates/module/create/files/base/testutil/keeper/{{moduleName}}.go.plush b/ignite/templates/module/create/files/base/testutil/keeper/{{moduleName}}.go.plush index bde969ac1b..b8885504b2 100644 --- a/ignite/templates/module/create/files/base/testutil/keeper/{{moduleName}}.go.plush +++ b/ignite/templates/module/create/files/base/testutil/keeper/{{moduleName}}.go.plush @@ -44,7 +44,9 @@ func <%= title(moduleName) %>Keeper(t testing.TB) (keeper.Keeper, sdk.Context) { ctx := sdk.NewContext(stateStore, cmtproto.Header{}, false, log.NewNopLogger()) // Initialize params - k.SetParams(ctx, types.DefaultParams()) + if err := k.SetParams(ctx, types.DefaultParams()); err != nil { + panic(err) + } return k, ctx } diff --git a/ignite/templates/module/create/files/base/x/{{moduleName}}/module/genesis.go.plush b/ignite/templates/module/create/files/base/x/{{moduleName}}/module/genesis.go.plush index ed35249792..dcc4618c92 100644 --- a/ignite/templates/module/create/files/base/x/{{moduleName}}/module/genesis.go.plush +++ b/ignite/templates/module/create/files/base/x/{{moduleName}}/module/genesis.go.plush @@ -10,7 +10,9 @@ import ( // InitGenesis initializes the module's state from a provided genesis state. func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { // this line is used by starport scaffolding # genesis/module/init - k.SetParams(ctx, genState.Params) + if err := k.SetParams(ctx, genState.Params); err != nil { + panic(err) + } } // ExportGenesis returns the module's exported genesis. diff --git a/ignite/templates/module/create/files/base/x/{{moduleName}}/module/simulation.go.plush b/ignite/templates/module/create/files/base/x/{{moduleName}}/module/simulation.go.plush index 9025cf691f..a890435c27 100644 --- a/ignite/templates/module/create/files/base/x/{{moduleName}}/module/simulation.go.plush +++ b/ignite/templates/module/create/files/base/x/{{moduleName}}/module/simulation.go.plush @@ -43,11 +43,6 @@ func (AppModule) GenerateGenesisState(simState *module.SimulationState) { // RegisterStoreDecoder registers a decoder. func (am AppModule) RegisterStoreDecoder(_ simtypes.StoreDecoderRegistry) {} -// ProposalContents doesn't return any content functions for governance proposals. -func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { - return nil -} - // WeightedOperations returns the all the gov module operations with their respective weights. func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { operations := make([]simtypes.WeightedOperation, 0) diff --git a/ignite/templates/module/create/files/ibc/testutil/keeper/{{moduleName}}.go.plush b/ignite/templates/module/create/files/ibc/testutil/keeper/{{moduleName}}.go.plush index 9dbc5263f6..f23c5a3dc5 100644 --- a/ignite/templates/module/create/files/ibc/testutil/keeper/{{moduleName}}.go.plush +++ b/ignite/templates/module/create/files/ibc/testutil/keeper/{{moduleName}}.go.plush @@ -63,7 +63,9 @@ func <%= title(moduleName) %>Keeper(t testing.TB) (keeper.Keeper, sdk.Context) { ctx := sdk.NewContext(stateStore, cmtproto.Header{}, false, log.NewNopLogger()) // Initialize params - k.SetParams(ctx, types.DefaultParams()) + if err := k.SetParams(ctx, types.DefaultParams()); err != nil { + panic(err) + } return k, ctx }