Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix all lint issue since golangci-lint bump #21326

Merged
merged 3 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
id: git_diff
with:
PATTERNS: |
**/*.mk
Makefile
**/Makefile
.golangci.yml
Expand Down
4 changes: 3 additions & 1 deletion client/v2/autocli/keyring/keyring.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import (

// KeyringContextKey is the key used to store the keyring in the context.
// The keyring must be wrapped using the KeyringImpl.
var KeyringContextKey struct{}
var KeyringContextKey keyringContextKey

type keyringContextKey struct{}

var _ Keyring = &KeyringImpl{}

Expand Down
4 changes: 4 additions & 0 deletions log/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Each entry must include the Github issue reference in the following format:

## [Unreleased]

## [v1.4.1](https://github.com/cosmos/cosmos-sdk/releases/tag/log/v1.4.1) - 2024-08-16

* [#21326](https://github.com/cosmos/cosmos-sdk/pull/21326) Avoid context key collision.

## [v1.4.0](https://github.com/cosmos/cosmos-sdk/releases/tag/log/v1.4.0) - 2024-08-07

* [#21045](https://github.com/cosmos/cosmos-sdk/pull/21045) Add `WithContext` method implementations to make all returned loggers compatible with `cosmossdk.io/core/log.Logger` (v1) without a direct dependency.
Expand Down
4 changes: 3 additions & 1 deletion log/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ func init() {
const ModuleKey = "module"

// ContextKey is used to store the logger in the context.
var ContextKey struct{}
var ContextKey contextKey

type contextKey struct{}

// Logger is the Cosmos SDK logger interface.
// It extends cosmossdk.io/core/log.Logger to return a child logger.
Expand Down
2 changes: 1 addition & 1 deletion simapp/simd/cmd/root_di.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import (
"cosmossdk.io/x/auth/tx"
authtxconfig "cosmossdk.io/x/auth/tx/config"
"cosmossdk.io/x/auth/types"
nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/config"
nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/server"
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/slashing/slashing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,5 @@ func TestSlashingMsgs(t *testing.T) {
headerInfo = header.Info{Height: app.LastBlockHeight() + 1}
_, _, err = sims.SignCheckDeliver(t, txConfig, app.BaseApp, headerInfo, []sdk.Msg{unjailMsg}, "", []uint64{0}, []uint64{1}, false, false, priv1)
require.Error(t, err)
require.True(t, errors.Is(types.ErrValidatorNotJailed, err))
require.True(t, errors.Is(err, types.ErrValidatorNotJailed))
}
2 changes: 1 addition & 1 deletion tests/systemtests/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func (s *SystemUnderTest) AwaitUpgradeInfo(t *testing.T) {
case err == nil:
found = true
case !os.IsNotExist(err):
t.Fatalf(err.Error())
t.Fatal(err.Error())
}
})
time.Sleep(s.blockTime / 2)
Expand Down
2 changes: 1 addition & 1 deletion tools/cosmovisor/cmd/cosmovisor/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestVersionCommand_Error(t *testing.T) {
rootCmd.SetOut(out)
rootCmd.SetErr(out)

ctx := context.WithValue(context.Background(), log.ContextKey, logger)
ctx := context.WithValue(context.Background(), log.ContextKey, logger) //nolint:staticcheck // temporary issue in dependency

require.Error(t, rootCmd.ExecuteContext(ctx))
require.Contains(t, out.String(), "DAEMON_NAME is not set")
Expand Down
8 changes: 4 additions & 4 deletions x/auth/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (s queryServer) Account(ctx context.Context, req *types.QueryAccountRequest

any, err := codectypes.NewAnyWithValue(account)
if err != nil {
return nil, status.Errorf(codes.Internal, err.Error())
return nil, status.Error(codes.Internal, err.Error())
}

return &types.QueryAccountResponse{Account: any}, nil
Expand Down Expand Up @@ -124,7 +124,7 @@ func (s queryServer) ModuleAccounts(ctx context.Context, req *types.QueryModuleA
}
any, err := codectypes.NewAnyWithValue(account)
if err != nil {
return nil, status.Errorf(codes.Internal, err.Error())
return nil, status.Error(codes.Internal, err.Error())
}
modAccounts = append(modAccounts, any)
}
Expand All @@ -150,7 +150,7 @@ func (s queryServer) ModuleAccountByName(ctx context.Context, req *types.QueryMo
}
any, err := codectypes.NewAnyWithValue(account)
if err != nil {
return nil, status.Errorf(codes.Internal, err.Error())
return nil, status.Error(codes.Internal, err.Error())
}

return &types.QueryModuleAccountByNameResponse{Account: any}, nil
Expand Down Expand Up @@ -234,7 +234,7 @@ func (s queryServer) AccountInfo(ctx context.Context, req *types.QueryAccountInf
if pubKey != nil {
pkAny, err = codectypes.NewAnyWithValue(account.GetPubKey())
if err != nil {
return nil, status.Errorf(codes.Internal, err.Error())
return nil, status.Error(codes.Internal, err.Error())
}
}

Expand Down
8 changes: 4 additions & 4 deletions x/authz/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (k Keeper) Grants(ctx context.Context, req *authz.QueryGrantsRequest) (*aut

authorizationAny, err := codectypes.NewAnyWithValue(authorization)
if err != nil {
return nil, status.Errorf(codes.Internal, err.Error())
return nil, status.Error(codes.Internal, err.Error())
}
return &authz.QueryGrantsResponse{
Grants: []*authz.Grant{{
Expand All @@ -70,7 +70,7 @@ func (k Keeper) Grants(ctx context.Context, req *authz.QueryGrantsRequest) (*aut

authorizationAny, err := codectypes.NewAnyWithValue(auth1)
if err != nil {
return nil, status.Errorf(codes.Internal, err.Error())
return nil, status.Error(codes.Internal, err.Error())
}
return &authz.Grant{
Authorization: authorizationAny,
Expand Down Expand Up @@ -111,7 +111,7 @@ func (k Keeper) GranterGrants(ctx context.Context, req *authz.QueryGranterGrants

any, err := codectypes.NewAnyWithValue(auth1)
if err != nil {
return nil, status.Errorf(codes.Internal, err.Error())
return nil, status.Error(codes.Internal, err.Error())
}

grantee := firstAddressFromGrantStoreKey(key)
Expand Down Expand Up @@ -166,7 +166,7 @@ func (k Keeper) GranteeGrants(ctx context.Context, req *authz.QueryGranteeGrants

authorizationAny, err := codectypes.NewAnyWithValue(auth1)
if err != nil {
return nil, status.Errorf(codes.Internal, err.Error())
return nil, status.Error(codes.Internal, err.Error())
}

granterAddr, err := k.authKeeper.AddressCodec().BytesToString(granter)
Expand Down
4 changes: 2 additions & 2 deletions x/distribution/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (k Querier) ValidatorOutstandingRewards(ctx context.Context, req *types.Que
}

if validator == nil {
return nil, errors.Wrapf(types.ErrNoValidatorExists, req.ValidatorAddress)
return nil, errors.Wrap(types.ErrNoValidatorExists, req.ValidatorAddress)
}

rewards, err := k.Keeper.ValidatorOutstandingRewards.Get(ctx, valAdr)
Expand Down Expand Up @@ -151,7 +151,7 @@ func (k Querier) ValidatorCommission(ctx context.Context, req *types.QueryValida
}

if validator == nil {
return nil, errors.Wrapf(types.ErrNoValidatorExists, req.ValidatorAddress)
return nil, errors.Wrap(types.ErrNoValidatorExists, req.ValidatorAddress)
}
commission, err := k.ValidatorsAccumulatedCommission.Get(ctx, valAdr)
if err != nil && !errors.IsOf(err, collections.ErrNotFound) {
Expand Down
2 changes: 1 addition & 1 deletion x/distribution/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func (k msgServer) DepositValidatorRewardsPool(ctx context.Context, msg *types.M
}

if validator == nil {
return nil, errors.Wrapf(types.ErrNoValidatorExists, msg.ValidatorAddress)
return nil, errors.Wrap(types.ErrNoValidatorExists, msg.ValidatorAddress)
}

// Allocate tokens from the distribution module to the validator, which are
Expand Down
2 changes: 1 addition & 1 deletion x/evidence/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (k Querier) Evidence(ctx context.Context, req *types.QueryEvidenceRequest)

evidenceAny, err := codectypes.NewAnyWithValue(msg)
if err != nil {
return nil, status.Errorf(codes.Internal, err.Error())
return nil, status.Error(codes.Internal, err.Error())
}

return &types.QueryEvidenceResponse{Evidence: evidenceAny}, nil
Expand Down
4 changes: 2 additions & 2 deletions x/feegrant/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (q Keeper) Allowance(ctx context.Context, req *feegrant.QueryAllowanceReque

feeAllowance, err := q.GetAllowance(ctx, granterAddr, granteeAddr)
if err != nil {
return nil, status.Errorf(codes.Internal, err.Error())
return nil, status.Error(codes.Internal, err.Error())
}

msg, ok := feeAllowance.(proto.Message)
Expand All @@ -45,7 +45,7 @@ func (q Keeper) Allowance(ctx context.Context, req *feegrant.QueryAllowanceReque

feeAllowanceAny, err := codectypes.NewAnyWithValue(msg)
if err != nil {
return nil, status.Errorf(codes.Internal, err.Error())
return nil, status.Error(codes.Internal, err.Error())
}

return &feegrant.QueryAllowanceResponse{
Expand Down
2 changes: 1 addition & 1 deletion x/gov/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ func (k msgServer) SudoExec(ctx context.Context, msg *v1.MsgSudoExec) (*v1.MsgSu
if err := k.BranchService.Execute(ctx, func(ctx context.Context) error {
// TODO add route check here
if err := k.MsgRouterService.CanInvoke(ctx, sdk.MsgTypeURL(sudoedMsg)); err != nil {
return errors.Wrapf(govtypes.ErrInvalidProposal, err.Error())
return errors.Wrap(govtypes.ErrInvalidProposal, err.Error())
}

msgResp, err = k.MsgRouterService.InvokeUntyped(ctx, sudoedMsg)
Expand Down
4 changes: 2 additions & 2 deletions x/gov/keeper/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ func (k Keeper) SubmitProposal(ctx context.Context, messages []sdk.Msg, metadata
if !bytes.Equal(signers[0], k.GetGovernanceAccount(ctx).GetAddress()) {
addr, err := k.authKeeper.AddressCodec().BytesToString(signers[0])
if err != nil {
return v1.Proposal{}, errorsmod.Wrapf(types.ErrInvalidSigner, err.Error())
return v1.Proposal{}, errorsmod.Wrap(types.ErrInvalidSigner, err.Error())
}
return v1.Proposal{}, errorsmod.Wrapf(types.ErrInvalidSigner, addr)
return v1.Proposal{}, errorsmod.Wrap(types.ErrInvalidSigner, addr)
}

if err := k.MsgRouterService.CanInvoke(ctx, sdk.MsgTypeURL(msg)); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion x/group/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ metadata example:

// Since the --from flag is not required on this CLI command, we
// ignore it, and just use the 1st proposer in the JSON file.
if prop.Proposers == nil || len(prop.Proposers) == 0 {
if len(prop.Proposers) == 0 {
return errors.New("no proposers specified in proposal")
}
err = cmd.Flags().Set(flags.FlagFrom, prop.Proposers[0])
Expand Down
2 changes: 1 addition & 1 deletion x/group/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ func (k Keeper) TallyProposalsAtVPEnd(ctx context.Context) error {
// is greater than defined MaxMetadataLen in the module configuration
func (k Keeper) assertMetadataLength(metadata, description string) error {
if uint64(len(metadata)) > k.config.MaxMetadataLen {
return errors.ErrMetadataTooLong.Wrapf(description)
return errors.ErrMetadataTooLong.Wrap(description)
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion x/slashing/keeper/signing_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (k Keeper) JailUntil(ctx context.Context, consAddr sdk.ConsAddress, jailTim
if err != nil {
return types.ErrNoSigningInfoFound.Wrapf("could not convert consensus address to string. Error: %s", err.Error())
}
return types.ErrNoSigningInfoFound.Wrapf(fmt.Sprintf("cannot jail validator with consensus address %s that does not have any signing information", addr))
return types.ErrNoSigningInfoFound.Wrapf("cannot jail validator with consensus address %s that does not have any signing information", addr)
}

signInfo.JailedUntil = jailTime
Expand Down
4 changes: 2 additions & 2 deletions x/upgrade/keeper/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func TestRequireFutureBlock(t *testing.T) {
s := setupTest(t, 10, map[int64]bool{})
err := s.keeper.ScheduleUpgrade(s.ctx, types.Plan{Name: "test", Height: s.ctx.HeaderInfo().Height - 1})
require.Error(t, err)
require.True(t, errors.Is(sdkerrors.ErrInvalidRequest, err), err)
require.True(t, errors.Is(err, sdkerrors.ErrInvalidRequest), err)
}

func TestDoHeightUpgrade(t *testing.T) {
Expand Down Expand Up @@ -223,7 +223,7 @@ func TestCantApplySameUpgradeTwice(t *testing.T) {
t.Log("Verify an executed upgrade \"test\" can't be rescheduled")
err = s.keeper.ScheduleUpgrade(s.ctx, types.Plan{Name: "test", Height: height})
require.Error(t, err)
require.True(t, errors.Is(sdkerrors.ErrInvalidRequest, err), err)
require.True(t, errors.Is(err, sdkerrors.ErrInvalidRequest), err)
}

func TestNoSpuriousUpgrades(t *testing.T) {
Expand Down
Loading