Skip to content

Commit

Permalink
fix: remove reduntant variable redefinition
Browse files Browse the repository at this point in the history
  • Loading branch information
notanatol committed Mar 5, 2024
1 parent b8d9ec8 commit 0a0fc20
Show file tree
Hide file tree
Showing 71 changed files with 80 additions and 124 deletions.
2 changes: 0 additions & 2 deletions pkg/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,6 @@ func TestPostageHeaderError(t *testing.T) {
)
content := []byte{7: 0} // 8 zeros
for _, endpoint := range endpoints {
endpoint := endpoint
t.Run(endpoint+": empty batch", func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -571,7 +570,6 @@ func TestPostageDirectAndDeferred(t *testing.T) {
t.Parallel()

for _, endpoint := range []string{"bytes", "bzz", "chunks"} {
endpoint := endpoint

if endpoint != "chunks" {
t.Run(endpoint+" deferred", func(t *testing.T) {
Expand Down
2 changes: 0 additions & 2 deletions pkg/api/balances_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,6 @@ func Test_peerBalanceHandler_invalidInputs(t *testing.T) {
}}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -387,7 +386,6 @@ func Test_compensatedPeerBalanceHandler_invalidInputs(t *testing.T) {
}}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down
2 changes: 0 additions & 2 deletions pkg/api/bytes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@ func TestBytesUploadHandlerInvalidInputs(t *testing.T) {
}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -364,7 +363,6 @@ func TestBytesGetHandlerInvalidInputs(t *testing.T) {
}}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down
7 changes: 2 additions & 5 deletions pkg/api/bzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,9 @@ func TestBzzUploadDownloadWithRedundancy(t *testing.T) {
})
}
for _, rLevel := range []redundancy.Level{1, 2, 3, 4} {
rLevel := rLevel

t.Run(fmt.Sprintf("level=%d", rLevel), func(t *testing.T) {
for _, encrypt := range []bool{false, true} {
encrypt := encrypt
shardCnt := rLevel.GetMaxShards()
parityCnt := rLevel.GetParities(shardCnt)
if encrypt {
Expand All @@ -229,7 +228,6 @@ func TestBzzUploadDownloadWithRedundancy(t *testing.T) {
case 3:
chunkCnt = shardCnt*shardCnt + 1
}
levels := levels
t.Run(fmt.Sprintf("encrypt=%v levels=%d chunks=%d", encrypt, levels, chunkCnt), func(t *testing.T) {
if levels > 2 && (encrypt == (rLevel%2 == 1)) {
t.Skip("skipping to save time")
Expand Down Expand Up @@ -618,7 +616,7 @@ func TestBzzFilesRangeRequests(t *testing.T) {
}

for _, upload := range uploads {
upload := upload

t.Run(upload.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -885,7 +883,6 @@ func Test_bzzDownloadHandler_invalidInputs(t *testing.T) {
}}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down
1 change: 0 additions & 1 deletion pkg/api/chequebook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,6 @@ func Test_chequebookLastPeerHandler_invalidInputs(t *testing.T) {
}}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down
1 change: 0 additions & 1 deletion pkg/api/chunk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ func TestChunkHandlersInvalidInputs(t *testing.T) {

method := http.MethodGet
for _, tc := range tests {
tc := tc
t.Run(method+" "+tc.name, func(t *testing.T) {
t.Parallel()

Expand Down
6 changes: 3 additions & 3 deletions pkg/api/cors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func TestCORSHeaders(t *testing.T) {
wantCORS: false,
},
} {
tc := tc

t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -156,7 +156,7 @@ func TestCors(t *testing.T) {
expectedMethods: "GET, HEAD",
},
} {
tc := tc

t.Run(tc.endpoint, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -212,7 +212,7 @@ func TestCorsStatus(t *testing.T) {
allowedMethods: "GET, HEAD",
},
} {
tc := tc

t.Run(tc.endpoint, func(t *testing.T) {
t.Parallel()

Expand Down
4 changes: 2 additions & 2 deletions pkg/api/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func Test_loggerGetHandler_invalidInputs(t *testing.T) {
}}

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

t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -244,7 +244,7 @@ func Test_loggerSetVerbosityHandler_invalidInputs(t *testing.T) {
}}

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

t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down
4 changes: 2 additions & 2 deletions pkg/api/peer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ func Test_peerConnectHandler_invalidInputs(t *testing.T) {
}}

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

t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -295,7 +295,7 @@ func Test_peerDisconnectHandler_invalidInputs(t *testing.T) {
}}

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

t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down
4 changes: 2 additions & 2 deletions pkg/api/pin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ func TestPinHandlersInvalidInputs(t *testing.T) {
}}

for _, method := range []string{http.MethodGet, http.MethodPost, http.MethodDelete} {
method := method

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

t.Run(method+" "+tc.name, func(t *testing.T) {
t.Parallel()

Expand Down
2 changes: 1 addition & 1 deletion pkg/api/pingpong_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func Test_pingpongHandler_invalidInputs(t *testing.T) {
}}

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

t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down
6 changes: 2 additions & 4 deletions pkg/api/postage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -790,8 +790,6 @@ func TestPostageAccessHandler(t *testing.T) {

for _, op1 := range success {
for _, op2 := range failure {
op1 := op1
op2 := op2
t.Run(op1.name+"-"+op2.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -935,7 +933,7 @@ func Test_postageGetStampBucketsHandler_invalidInputs(t *testing.T) {
}}

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

t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -997,7 +995,7 @@ func Test_postageGetStampHandler_invalidInputs(t *testing.T) {
}}

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

t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down
2 changes: 1 addition & 1 deletion pkg/api/pss_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ func TestPssPostHandlerInvalidInputs(t *testing.T) {
}}

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

t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down
2 changes: 1 addition & 1 deletion pkg/api/settlements_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ func Test_peerSettlementsHandler_invalidInputs(t *testing.T) {
}}

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

t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down
2 changes: 1 addition & 1 deletion pkg/api/staking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func Test_stakingDepositHandler_invalidInputs(t *testing.T) {
}}

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

t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down
4 changes: 2 additions & 2 deletions pkg/api/stewardship_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ func TestStewardshipInvalidInputs(t *testing.T) {
}}

for _, method := range []string{http.MethodGet, http.MethodPut} {
method := method

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

t.Run(method+" "+tc.name, func(t *testing.T) {
t.Parallel()

Expand Down
2 changes: 1 addition & 1 deletion pkg/api/subdomain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func TestSubdomains(t *testing.T) {
},
},
} {
tc := tc

t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down
4 changes: 2 additions & 2 deletions pkg/api/tag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,9 @@ func TestTagsHandlersInvalidInputs(t *testing.T) {
}}

for _, method := range []string{http.MethodGet, http.MethodDelete, http.MethodPatch} {
method := method

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

t.Run(method+" "+tc.name, func(t *testing.T) {
t.Parallel()

Expand Down
1 change: 0 additions & 1 deletion pkg/api/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,6 @@ func TestMapStructure(t *testing.T) {
want: &mapSwarmAddressTest{SwarmAddressVal: swarm.MustParseHexAddress("1234567890abcdef")},
}}
for _, tc := range tests {
tc := tc

t.Run(tc.name, func(t *testing.T) {
t.Parallel()
Expand Down
4 changes: 2 additions & 2 deletions pkg/auth/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestAuthorize(t *testing.T) {
},
}
for _, tC := range tt {
tC := tC

t.Run(tC.desc, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -130,7 +130,7 @@ func TestEnforce(t *testing.T) {
}

for _, tC := range tt {
tC := tC

t.Run(tC.desc, func(t *testing.T) {
t.Parallel()

Expand Down
4 changes: 2 additions & 2 deletions pkg/bmt/bmt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TestHasherEmptyData(t *testing.T) {
t.Parallel()

for _, count := range testSegmentCounts {
count := count

t.Run(fmt.Sprintf("%d_segments", count), func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -88,7 +88,7 @@ func TestSyncHasherCorrectness(t *testing.T) {
testData := testutil.RandBytesWithSeed(t, 4096, seed)

for _, count := range testSegmentCounts {
count := count

t.Run(fmt.Sprintf("segments_%v", count), func(t *testing.T) {
t.Parallel()
max := count * hashSize
Expand Down
2 changes: 1 addition & 1 deletion pkg/bmt/proof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func TestProof(t *testing.T) {
}

for i := 0; i < 128; i++ {
i := i

t.Run(fmt.Sprintf("segmentIndex %d", i), func(t *testing.T) {
t.Parallel()

Expand Down
4 changes: 1 addition & 3 deletions pkg/cac/cac_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ func TestChunkInvariantsNew(t *testing.T) {
wantErr: nil,
},
} {
cc := cc
t.Run(cc.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -135,7 +134,6 @@ func TestChunkInvariantsNewWithDataSpan(t *testing.T) {
wantErr: nil,
},
} {
cc := cc
t.Run(cc.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -219,7 +217,7 @@ func TestInvalid(t *testing.T) {
),
},
} {
tc := tc

t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down
4 changes: 2 additions & 2 deletions pkg/encryption/mock/mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestEncryptor_Encrypt(t *testing.T) {
wantErr: mock.ErrInvalidXORKey,
},
} {
tc := tc

t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -125,7 +125,7 @@ func TestEncryptor_Decrypt(t *testing.T) {
wantErr: mock.ErrInvalidXORKey,
},
} {
tc := tc

t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down
1 change: 0 additions & 1 deletion pkg/feeds/testing/lookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ func TestFinderRandomIntervals(t *testing.T, finderf func(storage.Getter, *feeds
t.Parallel()

for j := 0; j < 3; j++ {
j := j
t.Run(fmt.Sprintf("random intervals %d", j), func(t *testing.T) {
t.Parallel()

Expand Down
4 changes: 2 additions & 2 deletions pkg/file/buffer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestChunkPipe(t *testing.T) {
{swarm.ChunkSize, swarm.ChunkSize}, // on, on
}
for i, tc := range dataWrites {
tc := tc

t.Run(strconv.Itoa(i), func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -130,7 +130,7 @@ func TestCopyBuffer(t *testing.T) {
}

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

t.Run(fmt.Sprintf("buf_%-4d/data_size_%d", tc.readBufferSize, tc.dataSize), func(t *testing.T) {
t.Parallel()

Expand Down
Loading

0 comments on commit 0a0fc20

Please sign in to comment.