From a192ee3181ce52113a75705a5ef100d423082dbc Mon Sep 17 00:00:00 2001 From: Andi <36215014+ChengenH@users.noreply.github.com> Date: Mon, 9 Dec 2024 20:19:34 +0800 Subject: [PATCH] chore: use errors.New to replace fmt.Errorf with no parameters (#3437) * chore: use errors.New to replace fmt.Errorf with no parameters Signed-off-by: ChengenH * chore: remove repetitive words Signed-off-by: ChengenH --------- Signed-off-by: ChengenH Co-authored-by: MSalopek --- .changelog/v21.0.1/bug-fixes/3418-bump-cosmossdk-math.md | 2 +- .github/PULL_REQUEST_TEMPLATE.md | 2 +- CHANGELOG.md | 2 +- app/keepers/keepers.go | 4 ++-- app/sim/sim_state.go | 3 ++- cmd/gaiad/cmd/testnet_set_local_validator.go | 6 +++--- tests/e2e/http_util.go | 5 +++-- tests/interchain/chainsuite/chain.go | 5 +++-- tests/interchain/chainsuite/chain_ics.go | 3 ++- 9 files changed, 18 insertions(+), 14 deletions(-) diff --git a/.changelog/v21.0.1/bug-fixes/3418-bump-cosmossdk-math.md b/.changelog/v21.0.1/bug-fixes/3418-bump-cosmossdk-math.md index 77d28aea7ab..4e2a117d364 100644 --- a/.changelog/v21.0.1/bug-fixes/3418-bump-cosmossdk-math.md +++ b/.changelog/v21.0.1/bug-fixes/3418-bump-cosmossdk-math.md @@ -1,5 +1,5 @@ - Bump [cosmossdk.io/math](https://github.com/cosmos/cosmos-sdk/tree/main/math) to [v1.4.0](https://github.com/cosmos/cosmos-sdk/tree/math/v1.4.0) in order to - address the the [ASA-2024-010](https://github.com/cosmos/cosmos-sdk/security/advisories/GHSA-7225-m954-23v7) + address the [ASA-2024-010](https://github.com/cosmos/cosmos-sdk/security/advisories/GHSA-7225-m954-23v7) security advisory. ([\#3418](https://github.com/cosmos/gaia/pull/3418)) \ No newline at end of file diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 1036e0b387e..420ccbb60a0 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,4 +1,4 @@ -Please go the the `Preview` tab and select the appropriate sub-template: +Please go the `Preview` tab and select the appropriate sub-template: * [Production code](?expand=1&template=production.md) - for types `fix`, `feat`, and `refactor`. * [Docs](?expand=1&template=docs.md) - for documentation changes. diff --git a/CHANGELOG.md b/CHANGELOG.md index d3fe6e4c15f..c0118c36055 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ - Bump [cosmossdk.io/math](https://github.com/cosmos/cosmos-sdk/tree/main/math) to [v1.4.0](https://github.com/cosmos/cosmos-sdk/tree/math/v1.4.0) in order to - address the the [ASA-2024-010](https://github.com/cosmos/cosmos-sdk/security/advisories/GHSA-7225-m954-23v7) + address the [ASA-2024-010](https://github.com/cosmos/cosmos-sdk/security/advisories/GHSA-7225-m954-23v7) security advisory. ([\#3418](https://github.com/cosmos/gaia/pull/3418)) diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 54993a96ac8..1b07afe9ac2 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -1,7 +1,7 @@ package keepers import ( - "fmt" + "errors" "os" feemarketkeeper "github.com/skip-mev/feemarket/x/feemarket/keeper" @@ -600,7 +600,7 @@ func (r *DefaultFeemarketDenomResolver) ConvertToDenom(_ sdk.Context, coin sdk.D return coin, nil } - return sdk.DecCoin{}, fmt.Errorf("error resolving denom") + return sdk.DecCoin{}, errors.New("error resolving denom") } func (r *DefaultFeemarketDenomResolver) ExtraDenoms(_ sdk.Context) ([]string, error) { diff --git a/app/sim/sim_state.go b/app/sim/sim_state.go index 1c2845eb777..32848202bb8 100644 --- a/app/sim/sim_state.go +++ b/app/sim/sim_state.go @@ -2,6 +2,7 @@ package sim import ( "encoding/json" + "errors" "fmt" "io" "math/rand" @@ -245,7 +246,7 @@ func AppStateFromGenesisFileFn(r io.Reader, cdc codec.JSONCodec, genesisFile str a, ok := acc.GetCachedValue().(sdk.AccountI) if !ok { - return genesis, nil, fmt.Errorf("expected account") + return genesis, nil, errors.New("expected account") } // create simulator accounts diff --git a/cmd/gaiad/cmd/testnet_set_local_validator.go b/cmd/gaiad/cmd/testnet_set_local_validator.go index 1cf041e4d0a..d877d956201 100644 --- a/cmd/gaiad/cmd/testnet_set_local_validator.go +++ b/cmd/gaiad/cmd/testnet_set_local_validator.go @@ -89,7 +89,7 @@ func getCommandArgs(appOpts servertypes.AppOptions) (valArgs, error) { // validate and set validator operator address valoperAddress := cast.ToString(appOpts.Get(flagValidatorOperatorAddress)) if valoperAddress == "" { - return args, fmt.Errorf("invalid validator operator address string") + return args, errors.New("invalid validator operator address string") } _, err := sdk.ValAddressFromBech32(valoperAddress) if err != nil { @@ -100,7 +100,7 @@ func getCommandArgs(appOpts servertypes.AppOptions) (valArgs, error) { // validate and set validator pubkey validatorPubKey := cast.ToString(appOpts.Get(flagValidatorPubKey)) if validatorPubKey == "" { - return args, fmt.Errorf("invalid validator pubkey string") + return args, errors.New("invalid validator pubkey string") } decPubKey, err := base64.StdEncoding.DecodeString(validatorPubKey) if err != nil { @@ -135,7 +135,7 @@ func getCommandArgs(appOpts servertypes.AppOptions) (valArgs, error) { // home dir homeDir := cast.ToString(appOpts.Get(flags.FlagHome)) if homeDir == "" { - return args, fmt.Errorf("invalid home dir") + return args, errors.New("invalid home dir") } args.homeDir = homeDir diff --git a/tests/e2e/http_util.go b/tests/e2e/http_util.go index 593759ac8b7..ee9705fb82c 100644 --- a/tests/e2e/http_util.go +++ b/tests/e2e/http_util.go @@ -2,6 +2,7 @@ package e2e import ( "encoding/json" + "errors" "fmt" "io" "net/http" @@ -27,13 +28,13 @@ func readJSON(resp *http.Response) (map[string]interface{}, error) { body, readErr := io.ReadAll(resp.Body) if readErr != nil { - return nil, fmt.Errorf("failed to read Body") + return nil, errors.New("failed to read Body") } var data map[string]interface{} err := json.Unmarshal(body, &data) if err != nil { - return nil, fmt.Errorf("failed to unmarshal response body") + return nil, errors.New("failed to unmarshal response body") } return data, nil diff --git a/tests/interchain/chainsuite/chain.go b/tests/interchain/chainsuite/chain.go index b1ffcea8713..81a831cf370 100644 --- a/tests/interchain/chainsuite/chain.go +++ b/tests/interchain/chainsuite/chain.go @@ -3,6 +3,7 @@ package chainsuite import ( "context" "encoding/json" + "errors" "fmt" "strconv" "strings" @@ -194,9 +195,9 @@ func (c *Chain) Upgrade(ctx context.Context, upgradeName, version string) error defer timeoutCtxCancel() err = testutil.WaitForBlocks(timeoutCtx, int(haltHeight-height)+3, c) if err == nil { - return fmt.Errorf("chain should not produce blocks after halt height") + return errors.New("chain should not produce blocks after halt height") } else if timeoutCtx.Err() == nil { - return fmt.Errorf("chain should not produce blocks after halt height") + return errors.New("chain should not produce blocks after halt height") } height, err = c.Height(ctx) diff --git a/tests/interchain/chainsuite/chain_ics.go b/tests/interchain/chainsuite/chain_ics.go index fb4c9b38312..13b161ef2dc 100644 --- a/tests/interchain/chainsuite/chain_ics.go +++ b/tests/interchain/chainsuite/chain_ics.go @@ -3,6 +3,7 @@ package chainsuite import ( "context" "encoding/json" + "errors" "fmt" "path" "strconv" @@ -569,7 +570,7 @@ func (p *Chain) CheckCCV(ctx context.Context, consumer *Chain, relayer *Relayer, return err } if providerPowerBefore >= providerPower { - return fmt.Errorf("provider power did not increase after delegation") + return errors.New("provider power did not increase after delegation") } consumerPower, err := consumer.GetValidatorPower(ctx, consumerHex) if err != nil {