Skip to content

Commit

Permalink
refactor: run go lint
Browse files Browse the repository at this point in the history
Signed-off-by: Artur Troian <[email protected]>
  • Loading branch information
troian committed Oct 28, 2024
1 parent 0f825cc commit 459d52d
Show file tree
Hide file tree
Showing 25 changed files with 454 additions and 107 deletions.
1 change: 0 additions & 1 deletion go/cli/crisis_tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ func TestNewMsgVerifyInvariantTxCmd(t *testing.T) {
}

for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
cmd := cli.GetTxCrisisVerifyInvariantTxCmd()

Expand Down
5 changes: 3 additions & 2 deletions go/cli/deployment_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ import (

"pkg.akt.dev/go/sdl"

cflags "pkg.akt.dev/go/cli/flags"
cutils "pkg.akt.dev/go/node/cert/v1/utils"
dv1 "pkg.akt.dev/go/node/deployment/v1"
dv1beta4 "pkg.akt.dev/go/node/deployment/v1beta4"
"pkg.akt.dev/go/node/types/constants"

cflags "pkg.akt.dev/go/cli/flags"
)

var (
Expand Down Expand Up @@ -96,7 +97,7 @@ func GetTxDeploymentCreateCmd() *cobra.Command {
return fmt.Errorf("cannot generate DSEQ from last block height. node is catching up")
}

Check warning on line 98 in go/cli/deployment_tx.go

View check run for this annotation

Codecov / codecov/patch

go/cli/deployment_tx.go#L96-L98

Added lines #L96 - L98 were not covered by tests

id.DSeq = uint64(syncInfo.LatestBlockHeight)
id.DSeq = uint64(syncInfo.LatestBlockHeight) // nolint: gosec

Check warning on line 100 in go/cli/deployment_tx.go

View check run for this annotation

Codecov / codecov/patch

go/cli/deployment_tx.go#L100

Added line #L100 was not covered by tests
}

version, err := sdlManifest.Version()
Expand Down
24 changes: 0 additions & 24 deletions go/cli/distribution_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ withdraw_addr_enabled: false`,
}

for _, tc := range testCases {
tc := tc

s.Run(tc.name, func() {
cmd := cli.GetQueryDistributionParamsCmd()

Expand Down Expand Up @@ -143,8 +141,6 @@ func (s *DistributionCLITestSuite) TestGetCmdQueryValidatorDistributionInfo() {
}

for _, tc := range testCases {
tc := tc

s.Run(tc.name, func() {
cmd := cli.GetQueryDistributionValidatorDistributionInfoCmd()

Expand Down Expand Up @@ -196,8 +192,6 @@ func (s *DistributionCLITestSuite) TestGetCmdQueryValidatorOutstandingRewards()
}

for _, tc := range testCases {
tc := tc

s.Run(tc.name, func() {
cmd := cli.GetQueryDistributionValidatorOutstandingRewardsCmd()

Expand Down Expand Up @@ -250,8 +244,6 @@ func (s *DistributionCLITestSuite) TestGetCmdQueryValidatorCommission() {
}

for _, tc := range testCases {
tc := tc

s.Run(tc.name, func() {
cmd := cli.GetQueryDistributionValidatorCommissionCmd()

Expand Down Expand Up @@ -340,8 +332,6 @@ func (s *DistributionCLITestSuite) TestGetCmdQueryValidatorSlashes() {
}

for _, tc := range testCases {
tc := tc

s.Run(tc.name, func() {
cmd := cli.GetQueryDistributionValidatorSlashesCmd()

Expand Down Expand Up @@ -439,8 +429,6 @@ total: []`,
}

for _, tc := range testCases {
tc := tc

s.Run(tc.name, func() {
cmd := cli.GetQueryDistributionDelegatorRewardsCmd()

Expand Down Expand Up @@ -478,8 +466,6 @@ func (s *DistributionCLITestSuite) TestGetCmdQueryCommunityPool() {
}

for _, tc := range testCases {
tc := tc

s.Run(tc.name, func() {
cmd := cli.GetQueryDistributionCommunityPoolCmd()

Expand Down Expand Up @@ -539,8 +525,6 @@ func (s *DistributionCLITestSuite) TestNewWithdrawRewardsCmd() {
}

for _, tc := range testCases {
tc := tc

s.Run(tc.name, func() {
cmd := cli.GetTxDistributionWithdrawRewardsCmd()

Expand Down Expand Up @@ -588,8 +572,6 @@ func (s *DistributionCLITestSuite) TestNewWithdrawAllRewardsCmd() {
}

for _, tc := range testCases {
tc := tc

s.Run(tc.name, func() {
cmd := cli.GetTxDistributionWithdrawAllRewardsCmd()
out, err := clitestutil.ExecTestCLICmd(context.Background(), s.cctx, cmd, tc.args...)
Expand Down Expand Up @@ -636,8 +618,6 @@ func (s *DistributionCLITestSuite) TestNewSetWithdrawAddrCmd() {
}

for _, tc := range testCases {
tc := tc

s.Run(tc.name, func() {
cmd := cli.GetTxDistributionSetWithdrawAddrCmd()
out, err := clitestutil.ExecTestCLICmd(context.Background(), s.cctx, cmd, tc.args...)
Expand Down Expand Up @@ -683,8 +663,6 @@ func (s *DistributionCLITestSuite) TestNewFundCommunityPoolCmd() {
}

for _, tc := range testCases {
tc := tc

s.Run(tc.name, func() {
cmd := cli.GetTxDistributionFundCommunityPoolCmd()

Expand Down Expand Up @@ -721,8 +699,6 @@ func (s *DistributionCLITestSuite) TestNewWithdrawAllTokenizeShareRecordRewardCm
}

for _, tc := range testCases {
tc := tc

s.Run(tc.name, func() {
cmd := cli.GetTxDistributionWithdrawAllTokenizeShareRecordRewardCmd()

Expand Down
4 changes: 2 additions & 2 deletions go/cli/distribution_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,12 +339,12 @@ $ %s tx distribution withdraw-tokenize-share-rewards 1 --from mykey
cl := MustClientFromContext(ctx)
cctx := cl.ClientContext()

recordID, err := strconv.Atoi(args[0])
recordID, err := strconv.ParseUint(args[0], 10, 0)
if err != nil {
return err
}

Check warning on line 345 in go/cli/distribution_tx.go

View check run for this annotation

Codecov / codecov/patch

go/cli/distribution_tx.go#L322-L345

Added lines #L322 - L345 were not covered by tests

msg := types.NewMsgWithdrawTokenizeShareRecordReward(cctx.GetFromAddress(), uint64(recordID))
msg := types.NewMsgWithdrawTokenizeShareRecordReward(cctx.GetFromAddress(), recordID)

resp, err := cl.Tx().BroadcastMsgs(ctx, []sdk.Msg{msg})
if err != nil {
Expand Down
8 changes: 3 additions & 5 deletions go/cli/distribution_tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ import (
)

func Test_splitAndCall_NoMessages(t *testing.T) {
// clientCtx := client.Context{}

err := newSplitAndApply(nil, nil, nil, 10)
err := newSplitAndApply(context.TODO(), nil, nil, 10)
require.NoError(t, err, "")
}

Expand All @@ -36,8 +34,8 @@ func Test_splitAndCall_Splitting(t *testing.T) {

callCount := 0
err := newSplitAndApply(
nil,
func(_ context.Context, msgs []sdk.Msg, _ ...cclient.BroadcastOption) (interface{}, error) {
context.TODO(),
func(_ context.Context, msgs []sdk.Msg, _ ...cclient.BroadcastOption) (interface{}, error) {
callCount++

require.NotNil(t, msgs)
Expand Down
2 changes: 0 additions & 2 deletions go/cli/evidence_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ func TestGetQueryCmd(t *testing.T) {
}

for name, tc := range testCases {
tc := tc

t.Run(name, func(t *testing.T) {
cmd := cli.GetQueryEvidenceCmd()

Expand Down
6 changes: 0 additions & 6 deletions go/cli/feegrant_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ func (s *FeegrantCLITestSuite) TestCmdGetFeeGrant() {
}

for _, tc := range testCases {
tc := tc

s.Run(tc.name, func() {
cmd := cli.GetQueryFeeGrantCmd()
out, err := clitestutil.ExecTestCLICmd(context.Background(), s.cctx, cmd, tc.args...)
Expand Down Expand Up @@ -91,8 +89,6 @@ func (s *FeegrantCLITestSuite) TestCmdGetFeeGrantsByGrantee() {
}

for _, tc := range testCases {
tc := tc

s.Run(tc.name, func() {
cmd := cli.GetQueryFeeGrantsByGranteeCmd()

Expand Down Expand Up @@ -136,8 +132,6 @@ func (s *FeegrantCLITestSuite) TestCmdGetFeeGrantsByGranter() {
}

for _, tc := range testCases {
tc := tc

s.Run(tc.name, func() {
cmd := cli.GetQueryFeeGrantsByGranterCmd()
out, err := clitestutil.ExecTestCLICmd(context.Background(), cctx, cmd, tc.args...)
Expand Down
1 change: 0 additions & 1 deletion go/cli/feegrant_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,3 @@ func (s *FeegrantCLITestSuite) SetupSuite() {
}
s.accounts[1] = accounts[1].Address
}

8 changes: 0 additions & 8 deletions go/cli/feegrant_tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,6 @@ func (s *FeegrantCLITestSuite) TestNewCmdFeeGrant() {
}

for _, tc := range testCases {
tc := tc

s.Run(tc.name, func() {
cmd := cli.GetTxFeegrantGrantCmd()
out, err := clitestutil.ExecTestCLICmd(context.Background(), cctx, cmd, tc.args...)
Expand Down Expand Up @@ -356,8 +354,6 @@ func (s *FeegrantCLITestSuite) TestNewCmdRevokeFeegrant() {
}

for _, tc := range testCases {
tc := tc

s.Run(tc.name, func() {
cmd := cli.GetTxFeegrantRevokeCmd()
out, err := clitestutil.ExecTestCLICmd(context.Background(), cctx, cmd, tc.args...)
Expand Down Expand Up @@ -508,8 +504,6 @@ func (s *FeegrantCLITestSuite) TestFilteredFeeAllowance() {
}

for _, tc := range testCases {
tc := tc

s.Run(tc.name, func() {
cmd := cli.GetTxFeegrantGrantCmd()
out, err := clitestutil.ExecTestCLICmd(context.Background(), cctx, cmd, tc.args...)
Expand Down Expand Up @@ -597,8 +591,6 @@ func (s *FeegrantCLITestSuite) TestFilteredFeeAllowance() {
}

for _, tc := range cases {
tc := tc

s.Run(tc.name, func() {
err := tc.malleate()
s.Require().NoError(err)
Expand Down
6 changes: 0 additions & 6 deletions go/cli/mint_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ mint_denom: ""`,
}

for _, tc := range testCases {
tc := tc

t.Run(tc.name, func(t *testing.T) {
cmd := cli.GetQueryMintParamsCmd()

Expand Down Expand Up @@ -115,8 +113,6 @@ func TestGetQueryMintInflationCmd(t *testing.T) {
}

for _, tc := range testCases {
tc := tc

t.Run(tc.name, func(t *testing.T) {
cmd := cli.GetQueryMintInflationCmd()

Expand Down Expand Up @@ -169,8 +165,6 @@ func TestGetCmdQueryAnnualProvisions(t *testing.T) {
}

for _, tc := range testCases {
tc := tc

t.Run(tc.name, func(t *testing.T) {
cmd := cli.GetQueryMintAnnualProvisionsCmd()

Expand Down
4 changes: 0 additions & 4 deletions go/cli/slashing_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ func (s *SlashingCLITestSuite) TestGetCmdQuerySigningInfo() {
}

for _, tc := range testCases {
tc := tc

s.Run(tc.name, func() {
cmd := cli.GetQuerySlashingSigningInfoCmd()
cctx := s.cctx
Expand Down Expand Up @@ -127,8 +125,6 @@ func (s *SlashingCLITestSuite) TestGetCmdQueryParams() {
}

for _, tc := range testCases {
tc := tc

s.Run(tc.name, func() {
cmd := cli.GetQuerySlashingParamsCmd()
cctx := s.cctx
Expand Down
2 changes: 0 additions & 2 deletions go/cli/slashing_tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ func (s *SlashingCLITestSuite) TestNewUnjailTxCmd() {
}

for _, tc := range testCases {
tc := tc

s.Run(tc.name, func() {
cmd := cli.GetTxSlashingUnjailCmd()
cctx := s.cctx
Expand Down
4 changes: 2 additions & 2 deletions go/cli/staking_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -747,13 +747,13 @@ $ %s query staking tokenize-share-record-by-id [id]
ctx := cmd.Context()
cl := MustQueryClientFromContext(ctx)

id, err := strconv.Atoi(args[0])
id, err := strconv.ParseUint(args[0], 10, 0)
if err != nil {
return err
}

res, err := cl.Query().Staking().TokenizeShareRecordById(cmd.Context(), &types.QueryTokenizeShareRecordByIdRequest{
Id: uint64(id),
Id: id,
})
if err != nil {
return err
Expand Down
Loading

0 comments on commit 459d52d

Please sign in to comment.