From 1515856560378d07838a96d30c8b08db8ed105b4 Mon Sep 17 00:00:00 2001 From: zakir <80246097+zakir-code@users.noreply.github.com> Date: Wed, 23 Oct 2024 16:33:36 +0800 Subject: [PATCH] chore: remove unused local variables (#22340) --- .golangci.yml | 2 ++ simapp/export.go | 2 -- store/cachekv/store_test.go | 2 -- types/mempool/priority_nonce_test.go | 5 ----- x/staking/keeper/query_utils.go | 3 --- 5 files changed, 2 insertions(+), 12 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 9fa8a3398ac3..29c3e352b6ab 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -119,3 +119,5 @@ linters-settings: - regexpMust - appendAssign - ifElseChain + unused: + local-variables-are-used: false \ No newline at end of file diff --git a/simapp/export.go b/simapp/export.go index 28d15f507a9b..9600132dfedf 100644 --- a/simapp/export.go +++ b/simapp/export.go @@ -216,7 +216,6 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [] // update bond intra-tx counters. store := ctx.KVStore(app.GetKey(stakingtypes.StoreKey)) iter := storetypes.KVStoreReversePrefixIterator(store, stakingtypes.ValidatorsKey) - counter := int16(0) for ; iter.Valid(); iter.Next() { addr := sdk.ValAddress(stakingtypes.AddressFromValidatorsKey(iter.Key())) @@ -238,7 +237,6 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [] if err = app.StakingKeeper.SetValidator(ctx, validator); err != nil { panic(err) } - counter++ } if err := iter.Close(); err != nil { diff --git a/store/cachekv/store_test.go b/store/cachekv/store_test.go index 2885e7125476..de03b04ba3fa 100644 --- a/store/cachekv/store_test.go +++ b/store/cachekv/store_test.go @@ -552,7 +552,6 @@ func assertIterateDomainCheck(t *testing.T, st types.KVStore, mem corestore.KVSt require.NoError(t, err) krc := newKeyRangeCounter(r) - i := 0 for ; krc.valid(); krc.next() { require.True(t, itr.Valid()) @@ -569,7 +568,6 @@ func assertIterateDomainCheck(t *testing.T, st types.KVStore, mem corestore.KVSt itr.Next() itr2.Next() - i++ } require.False(t, itr.Valid()) diff --git a/types/mempool/priority_nonce_test.go b/types/mempool/priority_nonce_test.go index 3bfd7e4ba86c..73d61cb9c2e9 100644 --- a/types/mempool/priority_nonce_test.go +++ b/types/mempool/priority_nonce_test.go @@ -540,10 +540,8 @@ func (s *MempoolTestSuite) TestRandomTxOrderManyTimes() { // validateOrder checks that the txs are ordered by priority and nonce // in O(n^2) time by checking each tx against all the other txs func validateOrder(mtxs []sdk.Tx) error { - iterations := 0 var itxs []txSpec for i, mtx := range mtxs { - iterations++ tx := mtx.(testTx) itxs = append(itxs, txSpec{p: int(tx.priority), n: int(tx.nonce), a: tx.address, i: i}) } @@ -556,7 +554,6 @@ func validateOrder(mtxs []sdk.Tx) error { for _, a := range itxs { for _, b := range itxs { - iterations++ // when b is before a // when a is before b @@ -574,7 +571,6 @@ func validateOrder(mtxs []sdk.Tx) error { // find a tx with same sender as b and lower nonce found := false for _, c := range itxs { - iterations++ if c.a.Equals(b.a) && c.n < b.n && c.p <= a.p { found = true break @@ -588,7 +584,6 @@ func validateOrder(mtxs []sdk.Tx) error { } } } - // fmt.Printf("validation in iterations: %d\n", iterations) return nil } diff --git a/x/staking/keeper/query_utils.go b/x/staking/keeper/query_utils.go index 625984dbd44a..ee0b042b8433 100644 --- a/x/staking/keeper/query_utils.go +++ b/x/staking/keeper/query_utils.go @@ -65,12 +65,9 @@ func (k Keeper) GetDelegatorValidator( func (k Keeper) GetAllDelegatorDelegations(ctx context.Context, delegator sdk.AccAddress) ([]types.Delegation, error) { delegations := make([]types.Delegation, 0) - var i int64 rng := collections.NewPrefixedPairRange[sdk.AccAddress, sdk.ValAddress](delegator) err := k.Delegations.Walk(ctx, rng, func(key collections.Pair[sdk.AccAddress, sdk.ValAddress], del types.Delegation) (stop bool, err error) { delegations = append(delegations, del) - i++ - return false, nil }) if err != nil {