Skip to content

Commit

Permalink
Detect and clean unused local variables (#6062)
Browse files Browse the repository at this point in the history
  • Loading branch information
poszu committed Jun 24, 2024
1 parent 1be211b commit 1abf7ce
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 9 deletions.
4 changes: 4 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,10 @@ linters-settings:
# - suite-thelper
# - useless-assert

unused:
exported-fields-are-used: false
local-variables-are-used: false

issues:
# List of regexps of issue texts to exclude.
#
Expand Down
2 changes: 0 additions & 2 deletions genvm/vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2686,7 +2686,6 @@ func TestVestingData(t *testing.T) {

drained := uint64(0)
remaining := uint64(meta.Total)
fee := 0
// execute drain tx every 1000 layers
for i := constants.VestStart + 1; i < constants.VestEnd; i += 1000 {
before, err := vm.GetBalance(vestaddr)
Expand All @@ -2708,7 +2707,6 @@ func TestVestingData(t *testing.T) {
require.NoError(t, err)
require.Equal(t, types.TransactionSuccess, rst[0].TransactionResult.Status)
nonce++
fee += int(rst[0].Fee)
drained += drain.Uint64()
remaining -= drain.Uint64()

Expand Down
3 changes: 0 additions & 3 deletions hare3/eligibility/oracle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ func BenchmarkOracle_CalcEligibility(b *testing.B) {
lid := types.EpochID(5).FirstLayer()
o.createLayerData(lid, numOfMiners)

var eligibilityCount uint16
var nodeIDs []types.NodeID
for pubkey := range createIdentities(b.N) {
nodeIDs = append(nodeIDs, pubkey)
Expand All @@ -347,8 +346,6 @@ func BenchmarkOracle_CalcEligibility(b *testing.B) {
r.NoError(err)
r.True(valid)
}

eligibilityCount += res
}
}

Expand Down
2 changes: 0 additions & 2 deletions systest/tests/checkpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ func TestCheckpoint(t *testing.T) {

func ensureSmeshing(t *testing.T, tctx *testcontext.Context, cl *cluster.Cluster, stop uint32) {
numSmeshers := cl.Total() - cl.Bootnodes()
var got int
createdCh := make(chan *pb.Proposal, numSmeshers)
eg, _ := errgroup.WithContext(tctx)
for i := cl.Bootnodes(); i < cl.Total(); i++ {
Expand All @@ -200,7 +199,6 @@ func ensureSmeshing(t *testing.T, tctx *testcontext.Context, cl *cluster.Cluster
"eligibilities", len(proposal.Eligibilities),
"status", pb.Proposal_Status_name[int32(proposal.Status)],
)
got++
createdCh <- proposal
return false, nil
}
Expand Down
2 changes: 0 additions & 2 deletions txs/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,6 @@ func TestCache_Account_NotEvictedAfterApplyDueToNonceGap(t *testing.T) {
func TestCache_BuildFromScratch(t *testing.T) {
tc, accounts := createCache(t, 1000)
mtxs := make(map[types.Address][]*types.MeshTransaction)
totalNumTXs := 0
for principal, ta := range accounts {
numTXs := rand.Uint64() % 100
if numTXs == 0 {
Expand All @@ -1022,7 +1021,6 @@ func TestCache_BuildFromScratch(t *testing.T) {
ta.balance = minBalance
}
mtxs[principal] = genAndSaveTXs(t, tc.db, ta.signer, ta.nonce, ta.nonce+numTXs-1, time.Now())
totalNumTXs += int(numTXs)
}
buildCache(t, tc, accounts, mtxs)
}
Expand Down

0 comments on commit 1abf7ce

Please sign in to comment.