Skip to content

Commit c61d769

Browse files
authored
Merge pull request #334 from bandprotocol/fix-staticcheck
[Staticcheck] Update error string to be lower case
2 parents d604218 + 61be9bf commit c61d769

File tree

13 files changed

+32
-26
lines changed

13 files changed

+32
-26
lines changed

client/grpc/oracle/proof/proof.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func getProofsByKey(
149149
}
150150
}
151151
default:
152-
return nil, &ics23.ExistenceProof{}, &ics23.ExistenceProof{}, fmt.Errorf("Unknown proof ops found")
152+
return nil, &ics23.ExistenceProof{}, &ics23.ExistenceProof{}, fmt.Errorf("unknown proof ops found")
153153
}
154154
}
155155

client/grpc/oracle/proof/service.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"github.com/grpc-ecosystem/grpc-gateway/runtime"
1414

1515
"github.com/bandprotocol/chain/v2/x/oracle/types"
16-
oracletypes "github.com/bandprotocol/chain/v2/x/oracle/types"
1716
)
1817

1918
// RegisterProofService registers the node gRPC service on the provided gRPC router.
@@ -89,7 +88,7 @@ func (s proofServer) Proof(ctx context.Context, req *QueryProofRequest) (*QueryP
8988
}
9089

9190
// Unmarshal the value into a Result object
92-
var rs oracletypes.Result
91+
var rs types.Result
9392
types.ModuleCdc.MustUnmarshal(value, &rs)
9493

9594
// Create an OracleDataProof object with the relevant information
@@ -195,7 +194,7 @@ func (s proofServer) MultiProof(ctx context.Context, req *QueryMultiProofRequest
195194
}
196195

197196
// Unmarshal the value into a Result object
198-
var rs oracletypes.Result
197+
var rs types.Result
199198
types.ModuleCdc.MustUnmarshal(value, &rs)
200199

201200
// Create an OracleDataProof object with the relevant information

client/grpc/oracle/proof/signature.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func recoverETHAddress(msg, sig, signer []byte) ([]byte, uint8, error) {
4444
return crypto.PubkeyToAddress(*pubuc).Bytes(), 27 + i, nil
4545
}
4646
}
47-
return nil, 0, fmt.Errorf("No match address found")
47+
return nil, 0, fmt.Errorf("no match address found")
4848
}
4949

5050
func GetPrefix(t tmproto.SignedMsgType, height int64, round int64) ([]byte, error) {
@@ -126,7 +126,7 @@ func GetSignaturesAndPrefix(info *types.SignedHeader) ([]TMSignature, CommonEnco
126126
}
127127
}
128128
if len(addrs) == 0 {
129-
return nil, CommonEncodedVotePart{}, fmt.Errorf("No valid precommit")
129+
return nil, CommonEncodedVotePart{}, fmt.Errorf("no valid precommit")
130130
}
131131

132132
signatures := make([]TMSignature, len(addrs))

pkg/gzip/gzip_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func TestUncompress(t *testing.T) {
2222
require.NoError(t, err)
2323
require.Equal(t, file1, accFile)
2424

25-
accFile, err = gzip.Uncompress(gzipFile, 2)
25+
_, err = gzip.Uncompress(gzipFile, 2)
2626
require.Error(t, err)
2727

2828
_, err = gzip.Uncompress(file1, 999)

testing/chain.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
2929
commitmenttypes "github.com/cosmos/ibc-go/v7/modules/core/23-commitment/types"
3030
ibchost "github.com/cosmos/ibc-go/v7/modules/core/24-host"
31-
"github.com/cosmos/ibc-go/v7/modules/core/exported"
3231
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
3332
ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
3433
"github.com/cosmos/ibc-go/v7/testing/mock"
@@ -325,7 +324,7 @@ func (chain *TestChain) SendReport(
325324

326325
// GetClientState retrieves the client state for the provided clientID. The client is
327326
// expected to exist otherwise testing will fail.
328-
func (chain *TestChain) GetClientState(clientID string) exported.ClientState {
327+
func (chain *TestChain) GetClientState(clientID string) ibcexported.ClientState {
329328
clientState, found := chain.App.GetIBCKeeper().ClientKeeper.GetClientState(chain.GetContext(), clientID)
330329
require.True(chain.t, found)
331330

@@ -334,7 +333,10 @@ func (chain *TestChain) GetClientState(clientID string) exported.ClientState {
334333

335334
// GetConsensusState retrieves the consensus state for the provided clientID and height.
336335
// It will return a success boolean depending on if consensus state exists or not.
337-
func (chain *TestChain) GetConsensusState(clientID string, height exported.Height) (exported.ConsensusState, bool) {
336+
func (chain *TestChain) GetConsensusState(
337+
clientID string,
338+
height ibcexported.Height,
339+
) (ibcexported.ConsensusState, bool) {
338340
return chain.App.GetIBCKeeper().ClientKeeper.GetClientConsensusState(chain.GetContext(), clientID, height)
339341
}
340342

@@ -357,7 +359,7 @@ func (chain *TestChain) GetValsAtHeight(height int64) (*tmtypes.ValidatorSet, bo
357359

358360
// GetAcknowledgement retrieves an acknowledgement for the provided packet. If the
359361
// acknowledgement does not exist then testing will fail.
360-
func (chain *TestChain) GetAcknowledgement(packet exported.PacketI) []byte {
362+
func (chain *TestChain) GetAcknowledgement(packet ibcexported.PacketI) []byte {
361363
ack, found := chain.App.GetIBCKeeper().ChannelKeeper.GetPacketAcknowledgement(
362364
chain.GetContext(),
363365
packet.GetDestPort(),

x/bank/keeper/keeper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (k *WrappedBankKeeper) SetDistrKeeper(dk types.DistributionKeeper) {
4242

4343
// Logger returns a module-specific logger.
4444
func (k WrappedBankKeeper) Logger(ctx sdk.Context) log.Logger {
45-
return ctx.Logger().With("module", fmt.Sprint("x/wrappedbank"))
45+
return ctx.Logger().With("module", "x/wrappedbank")
4646
}
4747

4848
// BurnCoins moves the specified amount of coins from the given module name to

x/oracle/keeper/grpc_query.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ func (k Querier) RequestVerification(
341341
// Provided signature should be valid, which means this query request should be signed by the provided reporter
342342
pk, err := hex.DecodeString(req.Reporter)
343343
if err != nil || len(pk) != secp256k1.PubKeySize {
344-
return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("unable to get reporter's public key"))
344+
return nil, status.Error(codes.InvalidArgument, "unable to get reporter's public key")
345345
}
346346
reporterPubKey := secp256k1.PubKey(pk[:])
347347

x/oracle/keeper/owasm_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ func TestPrepareRequestSuccessBasic(t *testing.T) {
125125
sdk.WrapSDKContext(ctx),
126126
authtypes.NewQueryAllBalancesRequest(testapp.FeePayer.Address, &query.PageRequest{}),
127127
)
128+
require.NoError(t, err)
128129
feePayerBalances := balancesRes.Balances
129130

130131
// OracleScript#1: Prepare asks for DS#1,2,3 with ExtID#1,2,3 and calldata "beeb"
@@ -974,6 +975,7 @@ func TestCollectFeeBasicSuccess(t *testing.T) {
974975
sdk.WrapSDKContext(ctx),
975976
authtypes.NewQueryAllBalancesRequest(testapp.FeePayer.Address, &query.PageRequest{}),
976977
)
978+
require.NoError(t, err)
977979
feePayerBalances := balancesRes.Balances
978980
feePayerBalances[0].Amount = feePayerBalances[0].Amount.Sub(sdk.NewInt(3000000))
979981

@@ -1006,6 +1008,7 @@ func TestCollectFeeBasicSuccessWithOtherAskCount(t *testing.T) {
10061008
sdk.WrapSDKContext(ctx),
10071009
authtypes.NewQueryAllBalancesRequest(testapp.FeePayer.Address, &query.PageRequest{}),
10081010
)
1011+
require.NoError(t, err)
10091012
feePayerBalances := balancesRes.Balances
10101013
feePayerBalances[0].Amount = feePayerBalances[0].Amount.Sub(sdk.NewInt(12000000))
10111014

yoda/event.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ func GetEventValues(log sdk.ABCIMessageLog, evType string, evKey string) (res []
3535
func GetEventValue(log sdk.ABCIMessageLog, evType string, evKey string) (string, error) {
3636
values := GetEventValues(log, evType, evKey)
3737
if len(values) == 0 {
38-
return "", fmt.Errorf("Cannot find event with type: %s, key: %s", evType, evKey)
38+
return "", fmt.Errorf("cannot find event with type: %s, key: %s", evType, evKey)
3939
}
4040
if len(values) > 1 {
41-
return "", fmt.Errorf("Found more than one event with type: %s, key: %s", evType, evKey)
41+
return "", fmt.Errorf("found more than one event with type: %s, key: %s", evType, evKey)
4242
}
4343
return values[0], nil
4444
}

yoda/executor/executor.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ func NewExecutor(executor string) (exec Executor, err error) {
4141
case "rest":
4242
exec = NewRestExec(base, timeout)
4343
case "docker":
44-
return nil, fmt.Errorf("Docker executor is currently not supported")
44+
return nil, fmt.Errorf("docker executor is currently not supported")
4545
default:
46-
return nil, fmt.Errorf("Invalid executor name: %s, base: %s", name, base)
46+
return nil, fmt.Errorf("invalid executor name: %s, base: %s", name, base)
4747
}
4848

4949
// TODO: Remove hardcode in test execution
@@ -72,25 +72,25 @@ func NewExecutor(executor string) (exec Executor, err error) {
7272
func parseExecutor(executorStr string) (name string, base string, timeout time.Duration, err error) {
7373
executor := strings.SplitN(executorStr, ":", 2)
7474
if len(executor) != 2 {
75-
return "", "", 0, fmt.Errorf("Invalid executor, cannot parse executor: %s", executorStr)
75+
return "", "", 0, fmt.Errorf("invalid executor, cannot parse executor: %s", executorStr)
7676
}
7777
u, err := url.Parse(executor[1])
7878
if err != nil {
79-
return "", "", 0, fmt.Errorf("Invalid url, cannot parse %s to url with error: %s", executor[1], err.Error())
79+
return "", "", 0, fmt.Errorf("invalid url, cannot parse %s to url with error: %s", executor[1], err.Error())
8080
}
8181

8282
query := u.Query()
8383
timeoutStr := query.Get(flagQueryTimeout)
8484
if timeoutStr == "" {
85-
return "", "", 0, fmt.Errorf("Invalid timeout, executor requires query timeout")
85+
return "", "", 0, fmt.Errorf("invalid timeout, executor requires query timeout")
8686
}
8787
// Remove timeout from query because we need to return `base`
8888
query.Del(flagQueryTimeout)
8989
u.RawQuery = query.Encode()
9090

9191
timeout, err = time.ParseDuration(timeoutStr)
9292
if err != nil {
93-
return "", "", 0, fmt.Errorf("Invalid timeout, cannot parse duration with error: %s", err.Error())
93+
return "", "", 0, fmt.Errorf("invalid timeout, cannot parse duration with error: %s", err.Error())
9494
}
9595
return executor[0], u.String(), timeout, nil
9696
}

yoda/executor/executor_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ func TestParseExecutor(t *testing.T) {
2929

3030
func TestParseExecutorWithoutRawQuery(t *testing.T) {
3131
_, _, _, err := parseExecutor("beeb:www.beebprotocol.com")
32-
require.EqualError(t, err, "Invalid timeout, executor requires query timeout")
32+
require.EqualError(t, err, "invalid timeout, executor requires query timeout")
3333
}
3434

3535
func TestParseExecutorInvalidExecutorError(t *testing.T) {
3636
_, _, _, err := parseExecutor("beeb")
37-
require.EqualError(t, err, "Invalid executor, cannot parse executor: beeb")
37+
require.EqualError(t, err, "invalid executor, cannot parse executor: beeb")
3838
}
3939

4040
func TestParseExecutorInvalidTimeoutError(t *testing.T) {
4141
_, _, _, err := parseExecutor("beeb:www.beebprotocol.com?timeout=beeb")
42-
require.EqualError(t, err, "Invalid timeout, cannot parse duration with error: time: invalid duration \"beeb\"")
42+
require.EqualError(t, err, "invalid timeout, cannot parse duration with error: time: invalid duration \"beeb\"")
4343
}

yoda/executor/multi_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ func TestMultiExecOneWorking(t *testing.T) {
8080
exec2 := newMockExec([]byte("output"), 0, nil)
8181
exec3 := newMockExec(nil, 0, errors.New("error3"))
8282
exec, err := NewMultiExec([]Executor{exec1, exec2, exec3}, "round-robin")
83+
require.NoError(t, err)
8384
result, err := exec.Exec(nil, "", nil)
8485
require.NoError(t, err)
8586
require.Equal(t, ExecResult{Output: []byte("output"), Code: 0}, result)
@@ -96,6 +97,7 @@ func TestMultiExecAllErrors(t *testing.T) {
9697
exec2 := newMockExec(nil, 0, errors.New("error2"))
9798
exec3 := newMockExec(nil, 0, errors.New("error3"))
9899
exec, err := NewMultiExec([]Executor{exec1, exec2, exec3}, "round-robin")
100+
require.NoError(t, err)
99101
_, err = exec.Exec(nil, "", nil)
100102
require.EqualError(t, err, "MultiError: error1, error2, error3")
101103
_, err = exec.Exec(nil, "", nil)

yoda/run.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,14 @@ func runCmd(c *Context) *cobra.Command {
106106
Args: cobra.ExactArgs(0),
107107
RunE: func(cmd *cobra.Command, args []string) error {
108108
if cfg.ChainID == "" {
109-
return errors.New("Chain ID must not be empty")
109+
return errors.New("chain ID must not be empty")
110110
}
111111
keys, err := kb.List()
112112
if err != nil {
113113
return err
114114
}
115115
if len(keys) == 0 {
116-
return errors.New("No key available")
116+
return errors.New("no key available")
117117
}
118118
c.keys = keys
119119
c.validator, err = sdk.ValAddressFromBech32(cfg.Validator)

0 commit comments

Comments
 (0)