Skip to content

Commit

Permalink
chore: use errors.New to replace fmt.Errorf with no parameters (#3437)
Browse files Browse the repository at this point in the history
* chore: use errors.New to replace fmt.Errorf with no parameters

Signed-off-by: ChengenH <[email protected]>

* chore: remove repetitive words

Signed-off-by: ChengenH <[email protected]>

---------

Signed-off-by: ChengenH <[email protected]>
Co-authored-by: MSalopek <[email protected]>
  • Loading branch information
ChengenH and MSalopek authored Dec 9, 2024
1 parent 6d7b19c commit a192ee3
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .changelog/v21.0.1/bug-fixes/3418-bump-cosmossdk-math.md
Original file line number Diff line number Diff line change
@@ -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))
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
4 changes: 2 additions & 2 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package keepers

import (
"fmt"
"errors"
"os"

feemarketkeeper "github.com/skip-mev/feemarket/x/feemarket/keeper"
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion app/sim/sim_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package sim

import (
"encoding/json"
"errors"
"fmt"
"io"
"math/rand"
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions cmd/gaiad/cmd/testnet_set_local_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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

Expand Down
5 changes: 3 additions & 2 deletions tests/e2e/http_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package e2e

import (
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions tests/interchain/chainsuite/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package chainsuite
import (
"context"
"encoding/json"
"errors"
"fmt"
"strconv"
"strings"
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion tests/interchain/chainsuite/chain_ics.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package chainsuite
import (
"context"
"encoding/json"
"errors"
"fmt"
"path"
"strconv"
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit a192ee3

Please sign in to comment.