From 85bf43b1bb35c64ad4f1b1832b8ad406155df993 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 30 Jun 2022 10:31:00 -0400 Subject: [PATCH] chore!: var-naming linter errors (backport #12135) (#12401) --- CHANGELOG.md | 2 + x/auth/tx/service.go | 4 +- x/authz/keeper/keeper.go | 8 +- x/group/keeper/grpc_query.go | 4 +- x/group/keeper/msg_server.go | 8 +- x/group/keeper/tally.go | 4 +- x/nft/client/testutil/grpc.go | 160 +++++++++++++++++----------------- 7 files changed, 96 insertions(+), 94 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2076115c71a..5cb59207d50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/mint) [#12384](https://github.com/cosmos/cosmos-sdk/pull/12384) Ensure `GoalBonded` must be positive when performing `x/mint` parameter validation. * (x/auth) [#12261](https://github.com/cosmos/cosmos-sdk/pull/12261) Deprecate pagination in GetTxsEventRequest/Response in favor of page and limit to align with tendermint `SignClient.TxSearch` * (vesting) [#12190](https://github.com/cosmos/cosmos-sdk/pull/12190) Replace https://github.com/cosmos/cosmos-sdk/pull/12190 to use `NewBaseAccountWithAddress` in all vesting account message handlers. +* (linting) [#12135](https://github.com/cosmos/cosmos-sdk/pull/12135/) Fix variable naming issues per enabled linters. Run gofumpt to ensure easy reviews of ongoing linting work. +* (linting) [#12132](https://github.com/cosmos/cosmos-sdk/pull/12132) Change sdk.Int to math.Int, run `gofumpt -w -l .`, and `golangci-lint run ./... --fix` * (cli) [#12127](https://github.com/cosmos/cosmos-sdk/pull/12127) Fix the CLI not always taking into account `--fee-payer` and `--fee-granter` flags. * (migrations) [#12028](https://github.com/cosmos/cosmos-sdk/pull/12028) Fix v0.45->v0.46 in-place store migrations. * (baseapp) [#12089](https://github.com/cosmos/cosmos-sdk/pull/12089) Include antehandler and runMsgs events in SimulateTx. diff --git a/x/auth/tx/service.go b/x/auth/tx/service.go index 41db19607fe..7904bdcaccb 100644 --- a/x/auth/tx/service.go +++ b/x/auth/tx/service.go @@ -187,7 +187,7 @@ func (s txServer) GetBlockWithTxs(ctx context.Context, req *txtypes.GetBlockWith "or greater than the current height %d", req.Height, currentHeight) } - blockId, block, err := tmservice.GetProtoBlock(ctx, s.clientCtx, &req.Height) + blockID, block, err := tmservice.GetProtoBlock(ctx, s.clientCtx, &req.Height) if err != nil { return nil, err } @@ -236,7 +236,7 @@ func (s txServer) GetBlockWithTxs(ctx context.Context, req *txtypes.GetBlockWith return &txtypes.GetBlockWithTxsResponse{ Txs: txs, - BlockId: &blockId, + BlockId: &blockID, Block: block, Pagination: &pagination.PageResponse{ Total: blockTxsLn, diff --git a/x/authz/keeper/keeper.go b/x/authz/keeper/keeper.go index 5ccb7e0de6f..137e07dc944 100644 --- a/x/authz/keeper/keeper.go +++ b/x/authz/keeper/keeper.go @@ -323,10 +323,10 @@ func (keeper Keeper) removeFromGrantQueue(ctx sdk.Context, grantKey []byte, gran _, _, msgType := parseGrantStoreKey(grantKey) queueItems := queueItem.MsgTypeUrls - for index, typeUrl := range queueItems { + for index, typeURL := range queueItems { ctx.GasMeter().ConsumeGas(gasCostPerIteration, "grant queue") - if typeUrl == msgType { + if typeURL == msgType { end := len(queueItem.MsgTypeUrls) - 1 queueItems[index] = queueItems[end] queueItems = queueItems[:end] @@ -363,8 +363,8 @@ func (k Keeper) DequeueAndDeleteExpiredGrants(ctx sdk.Context) error { store.Delete(iterator.Key()) - for _, typeUrl := range queueItem.MsgTypeUrls { - store.Delete(grantStoreKey(grantee, granter, typeUrl)) + for _, typeURL := range queueItem.MsgTypeUrls { + store.Delete(grantStoreKey(grantee, granter, typeURL)) } } diff --git a/x/group/keeper/grpc_query.go b/x/group/keeper/grpc_query.go index f9bef8c8b22..ff26844dde5 100644 --- a/x/group/keeper/grpc_query.go +++ b/x/group/keeper/grpc_query.go @@ -321,9 +321,9 @@ func (k Keeper) getVotesByVoter(ctx sdk.Context, voter sdk.AccAddress, pageReque // TallyResult computes the live tally result of a proposal. func (k Keeper) TallyResult(goCtx context.Context, request *group.QueryTallyResultRequest) (*group.QueryTallyResultResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - proposalId := request.ProposalId + proposalID := request.ProposalId - proposal, err := k.getProposal(ctx, proposalId) + proposal, err := k.getProposal(ctx, proposalID) if err != nil { return nil, err } diff --git a/x/group/keeper/msg_server.go b/x/group/keeper/msg_server.go index 6a25c5dce3f..a4f7fe2e2a8 100644 --- a/x/group/keeper/msg_server.go +++ b/x/group/keeper/msg_server.go @@ -248,12 +248,12 @@ func (k Keeper) CreateGroupWithPolicy(goCtx context.Context, req *group.MsgCreat if err != nil { return nil, sdkerrors.Wrap(err, "group response") } - groupId := groupRes.GroupId + groupID := groupRes.GroupId var groupPolicyAddr sdk.AccAddress groupPolicyRes, err := k.CreateGroupPolicy(goCtx, &group.MsgCreateGroupPolicy{ Admin: req.Admin, - GroupId: groupId, + GroupId: groupID, Metadata: req.GroupPolicyMetadata, DecisionPolicy: req.DecisionPolicy, }) @@ -270,7 +270,7 @@ func (k Keeper) CreateGroupWithPolicy(goCtx context.Context, req *group.MsgCreat if req.GroupPolicyAsAdmin { updateAdminReq := &group.MsgUpdateGroupAdmin{ - GroupId: groupId, + GroupId: groupID, Admin: req.Admin, NewAdmin: groupPolicyAddress, } @@ -290,7 +290,7 @@ func (k Keeper) CreateGroupWithPolicy(goCtx context.Context, req *group.MsgCreat } } - return &group.MsgCreateGroupWithPolicyResponse{GroupId: groupId, GroupPolicyAddress: groupPolicyAddress}, nil + return &group.MsgCreateGroupWithPolicyResponse{GroupId: groupID, GroupPolicyAddress: groupPolicyAddress}, nil } func (k Keeper) CreateGroupPolicy(goCtx context.Context, req *group.MsgCreateGroupPolicy) (*group.MsgCreateGroupPolicyResponse, error) { diff --git a/x/group/keeper/tally.go b/x/group/keeper/tally.go index 931c949696c..d3ffedfd5ed 100644 --- a/x/group/keeper/tally.go +++ b/x/group/keeper/tally.go @@ -10,7 +10,7 @@ import ( // Tally is a function that tallies a proposal by iterating through its votes, // and returns the tally result without modifying the proposal or any state. -func (k Keeper) Tally(ctx sdk.Context, p group.Proposal, groupId uint64) (group.TallyResult, error) { +func (k Keeper) Tally(ctx sdk.Context, p group.Proposal, groupID uint64) (group.TallyResult, error) { // If proposal has already been tallied and updated, then its status is // accepted/rejected, in which case we just return the previously stored result. // @@ -40,7 +40,7 @@ func (k Keeper) Tally(ctx sdk.Context, p group.Proposal, groupId uint64) (group. var member group.GroupMember err := k.groupMemberTable.GetOne(ctx.KVStore(k.key), orm.PrimaryKey(&group.GroupMember{ - GroupId: groupId, + GroupId: groupID, Member: &group.Member{Address: vote.Voter}, }), &member) diff --git a/x/nft/client/testutil/grpc.go b/x/nft/client/testutil/grpc.go index 8d98182c5b7..11ba5b77724 100644 --- a/x/nft/client/testutil/grpc.go +++ b/x/nft/client/testutil/grpc.go @@ -12,7 +12,7 @@ func (s *IntegrationTestSuite) TestQueryBalanceGRPC() { testCases := []struct { name string args struct { - ClassId string + ClassID string Owner string } expectErr bool @@ -22,10 +22,10 @@ func (s *IntegrationTestSuite) TestQueryBalanceGRPC() { { name: "fail not exist class id", args: struct { - ClassId string + ClassID string Owner string }{ - ClassId: "invalid_class_id", + ClassID: "invalid_class_id", Owner: s.owner.String(), }, expectErr: true, @@ -35,10 +35,10 @@ func (s *IntegrationTestSuite) TestQueryBalanceGRPC() { { name: "fail not exist owner", args: struct { - ClassId string + ClassID string Owner string }{ - ClassId: ExpNFT.ClassId, + ClassID: ExpNFT.ClassId, Owner: s.owner.String(), }, expectErr: false, @@ -47,10 +47,10 @@ func (s *IntegrationTestSuite) TestQueryBalanceGRPC() { { name: "success", args: struct { - ClassId string + ClassID string Owner string }{ - ClassId: ExpNFT.ClassId, + ClassID: ExpNFT.ClassId, Owner: val.Address.String(), }, expectErr: false, @@ -59,7 +59,7 @@ func (s *IntegrationTestSuite) TestQueryBalanceGRPC() { } balanceURL := val.APIAddress + "/cosmos/nft/v1beta1/balance/%s/%s" for _, tc := range testCases { - uri := fmt.Sprintf(balanceURL, tc.args.Owner, tc.args.ClassId) + uri := fmt.Sprintf(balanceURL, tc.args.Owner, tc.args.ClassID) s.Run(tc.name, func() { resp, _ := rest.GetRequest(uri) if tc.expectErr { @@ -80,8 +80,8 @@ func (s *IntegrationTestSuite) TestQueryOwnerGRPC() { testCases := []struct { name string args struct { - ClassId string - Id string + ClassID string + ID string } expectErr bool errMsg string @@ -90,11 +90,11 @@ func (s *IntegrationTestSuite) TestQueryOwnerGRPC() { { name: "class id is invalid", args: struct { - ClassId string - Id string + ClassID string + ID string }{ - ClassId: "invalid_class_id", - Id: ExpNFT.Id, + ClassID: "invalid_class_id", + ID: ExpNFT.Id, }, expectErr: true, errMsg: "invalid class id", @@ -103,11 +103,11 @@ func (s *IntegrationTestSuite) TestQueryOwnerGRPC() { { name: "class id does not exist", args: struct { - ClassId string - Id string + ClassID string + ID string }{ - ClassId: "class-id", - Id: ExpNFT.Id, + ClassID: "class-id", + ID: ExpNFT.Id, }, expectErr: false, expectResult: "", @@ -115,11 +115,11 @@ func (s *IntegrationTestSuite) TestQueryOwnerGRPC() { { name: "nft id is invalid", args: struct { - ClassId string - Id string + ClassID string + ID string }{ - ClassId: ExpNFT.ClassId, - Id: "invalid_nft_id", + ClassID: ExpNFT.ClassId, + ID: "invalid_nft_id", }, expectErr: true, expectResult: "", @@ -127,11 +127,11 @@ func (s *IntegrationTestSuite) TestQueryOwnerGRPC() { { name: "nft id does not exist", args: struct { - ClassId string - Id string + ClassID string + ID string }{ - ClassId: ExpNFT.ClassId, - Id: "nft-id", + ClassID: ExpNFT.ClassId, + ID: "nft-id", }, expectErr: false, expectResult: "", @@ -139,11 +139,11 @@ func (s *IntegrationTestSuite) TestQueryOwnerGRPC() { { name: "nft exist", args: struct { - ClassId string - Id string + ClassID string + ID string }{ - ClassId: ExpNFT.ClassId, - Id: ExpNFT.Id, + ClassID: ExpNFT.ClassId, + ID: ExpNFT.Id, }, expectErr: false, expectResult: val.Address.String(), @@ -151,7 +151,7 @@ func (s *IntegrationTestSuite) TestQueryOwnerGRPC() { } ownerURL := val.APIAddress + "/cosmos/nft/v1beta1/owner/%s/%s" for _, tc := range testCases { - uri := fmt.Sprintf(ownerURL, tc.args.ClassId, tc.args.Id) + uri := fmt.Sprintf(ownerURL, tc.args.ClassID, tc.args.ID) s.Run(tc.name, func() { resp, err := rest.GetRequest(uri) if tc.expectErr { @@ -173,7 +173,7 @@ func (s *IntegrationTestSuite) TestQuerySupplyGRPC() { testCases := []struct { name string args struct { - ClassId string + ClassID string } expectErr bool errMsg string @@ -182,9 +182,9 @@ func (s *IntegrationTestSuite) TestQuerySupplyGRPC() { { name: "class id is invalid", args: struct { - ClassId string + ClassID string }{ - ClassId: "invalid_class_id", + ClassID: "invalid_class_id", }, expectErr: true, errMsg: "invalid class id", @@ -193,9 +193,9 @@ func (s *IntegrationTestSuite) TestQuerySupplyGRPC() { { name: "class id does not exist", args: struct { - ClassId string + ClassID string }{ - ClassId: "class-id", + ClassID: "class-id", }, expectErr: false, expectResult: 0, @@ -203,9 +203,9 @@ func (s *IntegrationTestSuite) TestQuerySupplyGRPC() { { name: "class id exist", args: struct { - ClassId string + ClassID string }{ - ClassId: ExpNFT.ClassId, + ClassID: ExpNFT.ClassId, }, expectErr: false, expectResult: 1, @@ -213,7 +213,7 @@ func (s *IntegrationTestSuite) TestQuerySupplyGRPC() { } supplyURL := val.APIAddress + "/cosmos/nft/v1beta1/supply/%s" for _, tc := range testCases { - uri := fmt.Sprintf(supplyURL, tc.args.ClassId) + uri := fmt.Sprintf(supplyURL, tc.args.ClassID) s.Run(tc.name, func() { resp, err := rest.GetRequest(uri) if tc.expectErr { @@ -234,7 +234,7 @@ func (s *IntegrationTestSuite) TestQueryNFTsGRPC() { testCases := []struct { name string args struct { - ClassId string + ClassID string Owner string } expectErr bool @@ -244,7 +244,7 @@ func (s *IntegrationTestSuite) TestQueryNFTsGRPC() { { name: "classID and owner are both empty", args: struct { - ClassId string + ClassID string Owner string }{}, errorMsg: "must provide at least one of classID or owner", @@ -254,10 +254,10 @@ func (s *IntegrationTestSuite) TestQueryNFTsGRPC() { { name: "classID is invalid", args: struct { - ClassId string + ClassID string Owner string }{ - ClassId: "invalid_class_id", + ClassID: "invalid_class_id", }, expectErr: true, expectResult: []*nft.NFT{}, @@ -265,10 +265,10 @@ func (s *IntegrationTestSuite) TestQueryNFTsGRPC() { { name: "classID does not exist", args: struct { - ClassId string + ClassID string Owner string }{ - ClassId: "class-id", + ClassID: "class-id", }, expectErr: false, expectResult: []*nft.NFT{}, @@ -276,10 +276,10 @@ func (s *IntegrationTestSuite) TestQueryNFTsGRPC() { { name: "success query by classID", args: struct { - ClassId string + ClassID string Owner string }{ - ClassId: ExpNFT.ClassId, + ClassID: ExpNFT.ClassId, }, expectErr: false, expectResult: []*nft.NFT{&ExpNFT}, @@ -287,7 +287,7 @@ func (s *IntegrationTestSuite) TestQueryNFTsGRPC() { { name: "success query by owner", args: struct { - ClassId string + ClassID string Owner string }{ Owner: val.Address.String(), @@ -298,10 +298,10 @@ func (s *IntegrationTestSuite) TestQueryNFTsGRPC() { { name: "success query by owner and classID", args: struct { - ClassId string + ClassID string Owner string }{ - ClassId: ExpNFT.ClassId, + ClassID: ExpNFT.ClassId, Owner: val.Address.String(), }, expectErr: false, @@ -310,7 +310,7 @@ func (s *IntegrationTestSuite) TestQueryNFTsGRPC() { } nftsOfClassURL := val.APIAddress + "/cosmos/nft/v1beta1/nfts?class_id=%s&owner=%s" for _, tc := range testCases { - uri := fmt.Sprintf(nftsOfClassURL, tc.args.ClassId, tc.args.Owner) + uri := fmt.Sprintf(nftsOfClassURL, tc.args.ClassID, tc.args.Owner) s.Run(tc.name, func() { resp, err := rest.GetRequest(uri) if tc.expectErr { @@ -331,8 +331,8 @@ func (s *IntegrationTestSuite) TestQueryNFTGRPC() { testCases := []struct { name string args struct { - ClassId string - Id string + ClassID string + ID string } expectErr bool errorMsg string @@ -340,11 +340,11 @@ func (s *IntegrationTestSuite) TestQueryNFTGRPC() { { name: "class id is invalid", args: struct { - ClassId string - Id string + ClassID string + ID string }{ - ClassId: "invalid_class_id", - Id: ExpNFT.Id, + ClassID: "invalid_class_id", + ID: ExpNFT.Id, }, expectErr: true, errorMsg: "invalid class id", @@ -352,11 +352,11 @@ func (s *IntegrationTestSuite) TestQueryNFTGRPC() { { name: "class id does not exist", args: struct { - ClassId string - Id string + ClassID string + ID string }{ - ClassId: "class", - Id: ExpNFT.Id, + ClassID: "class", + ID: ExpNFT.Id, }, expectErr: true, errorMsg: "not found nft", @@ -364,11 +364,11 @@ func (s *IntegrationTestSuite) TestQueryNFTGRPC() { { name: "nft id is invalid", args: struct { - ClassId string - Id string + ClassID string + ID string }{ - ClassId: ExpNFT.ClassId, - Id: "invalid_nft_id", + ClassID: ExpNFT.ClassId, + ID: "invalid_nft_id", }, expectErr: true, errorMsg: "invalid nft id", @@ -376,11 +376,11 @@ func (s *IntegrationTestSuite) TestQueryNFTGRPC() { { name: "nft id does not exist", args: struct { - ClassId string - Id string + ClassID string + ID string }{ - ClassId: ExpNFT.ClassId, - Id: "nft-id", + ClassID: ExpNFT.ClassId, + ID: "nft-id", }, expectErr: true, errorMsg: "not found nft", @@ -388,18 +388,18 @@ func (s *IntegrationTestSuite) TestQueryNFTGRPC() { { name: "exist nft", args: struct { - ClassId string - Id string + ClassID string + ID string }{ - ClassId: ExpNFT.ClassId, - Id: ExpNFT.Id, + ClassID: ExpNFT.ClassId, + ID: ExpNFT.Id, }, expectErr: false, }, } nftURL := val.APIAddress + "/cosmos/nft/v1beta1/nfts/%s/%s" for _, tc := range testCases { - uri := fmt.Sprintf(nftURL, tc.args.ClassId, tc.args.Id) + uri := fmt.Sprintf(nftURL, tc.args.ClassID, tc.args.ID) s.Run(tc.name, func() { resp, err := rest.GetRequest(uri) if tc.expectErr { @@ -420,7 +420,7 @@ func (s *IntegrationTestSuite) TestQueryClassGRPC() { testCases := []struct { name string args struct { - ClassId string + ClassID string } expectErr bool errorMsg string @@ -428,9 +428,9 @@ func (s *IntegrationTestSuite) TestQueryClassGRPC() { { name: "class id does not exist", args: struct { - ClassId string + ClassID string }{ - ClassId: "class-id", + ClassID: "class-id", }, expectErr: true, errorMsg: "not found class", @@ -438,16 +438,16 @@ func (s *IntegrationTestSuite) TestQueryClassGRPC() { { name: "class id exist", args: struct { - ClassId string + ClassID string }{ - ClassId: ExpNFT.ClassId, + ClassID: ExpNFT.ClassId, }, expectErr: false, }, } classURL := val.APIAddress + "/cosmos/nft/v1beta1/classes/%s" for _, tc := range testCases { - uri := fmt.Sprintf(classURL, tc.args.ClassId) + uri := fmt.Sprintf(classURL, tc.args.ClassID) s.Run(tc.name, func() { resp, err := rest.GetRequest(uri) if tc.expectErr {