Skip to content

Commit 6e99434

Browse files
committed
refactor: remove redundant variable declarations in for loops
Signed-off-by: efcking <efcking@outlook.com>
1 parent 3d0d2f1 commit 6e99434

104 files changed

Lines changed: 4 additions & 224 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cmd/ttn-lw-cli/commands/events.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ var eventsCommand = &cobra.Command{
7474
}()
7575

7676
for _, address := range getEventsAddresses() {
77-
address := address // shadow loop variable.
7877
g.Go(func() error {
7978
conn, err := api.Dial(gCtx, address)
8079
if err != nil {
@@ -137,7 +136,6 @@ var eventsFindRelatedCommand = &cobra.Command{
137136
}()
138137

139138
for _, address := range getEventsAddresses() {
140-
address := address // shadow loop variable.
141139
g.Go(func() error {
142140
conn, err := api.Dial(gCtx, address)
143141
if err != nil {

pkg/applicationserver/grpc_deviceregistry_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1163,7 +1163,6 @@ func TestDeviceRegistryBatchDelete(t *testing.T) { // nolint:paralleltest
11631163
BatchDeleteCalls: 1,
11641164
},
11651165
} {
1166-
tc := tc
11671166
test.RunSubtest(t, test.SubtestConfig{
11681167
Name: tc.Name,
11691168
Parallel: true,

pkg/applicationserver/io/mqtt/topics/v3_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ func TestV3AcceptedTopic(t *testing.T) {
6464
OK: true,
6565
},
6666
} {
67-
tc := tc
6867
t.Run(strconv.Itoa(i), func(t *testing.T) {
6968
t.Parallel()
7069
a := assertions.New(t)
@@ -139,7 +138,6 @@ func TestV3Topics(t *testing.T) {
139138
Expected: fmt.Sprintf("v3/%s/devices/%s/down/replace", appUID, devID),
140139
},
141140
} {
142-
tc := tc
143141
t.Run(tc.Expected, func(t *testing.T) {
144142
t.Parallel()
145143
actual := strings.Join(tc.Fn(appUID, devID), "/")

pkg/applicationserver/io/packages/alcsync/v1/alcsync_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ func TestNewTimeSyncCommand(t *testing.T) {
137137
}
138138

139139
for _, tc := range testCases {
140-
tc := tc
141140
t.Run(tc.Name, func(t *testing.T) {
142141
t.Parallel()
143142
a, _ := test.New(t)
@@ -205,7 +204,6 @@ func TestMakeCommandValidInput(t *testing.T) {
205204
var fPort uint32
206205

207206
for _, tc := range testCases {
208-
tc := tc
209207
t.Run(tc.Name, func(t *testing.T) {
210208
t.Parallel()
211209
a, _ := test.New(t)
@@ -273,7 +271,6 @@ func TestMakeCommandInvalidInput(t *testing.T) {
273271
var fPort uint32
274272

275273
for _, tc := range testCases {
276-
tc := tc
277274
t.Run(tc.Name, func(t *testing.T) {
278275
t.Parallel()
279276
a, _ := test.New(t)
@@ -467,7 +464,6 @@ func TestMakeCommandsValidInput(t *testing.T) {
467464
}
468465

469466
for _, tc := range testCases {
470-
tc := tc
471467
t.Run(tc.Name, func(t *testing.T) {
472468
t.Parallel()
473469
a, _ := test.New(t)
@@ -589,7 +585,6 @@ func TestMakeDownlinkSerializesAppTimeAns(t *testing.T) {
589585
}
590586

591587
for _, tc := range testCases {
592-
tc := tc
593588
t.Run(tc.Name, func(t *testing.T) {
594589
t.Parallel()
595590
a, _ := test.New(t)

pkg/applicationserver/io/packages/alcsync/v1/data_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ func TestPackageDataHandlesInvalidValues(t *testing.T) {
6666
}
6767

6868
for _, tc := range testCases {
69-
tc := tc
7069
t.Run(tc.Name, func(t *testing.T) {
7170
t.Parallel()
7271
a, _ := test.New(t)
@@ -222,7 +221,6 @@ func TestPackageDataMerge(t *testing.T) {
222221
}
223222

224223
for _, tc := range testCases {
225-
tc := tc
226224
t.Run(tc.Name, func(t *testing.T) {
227225
t.Parallel()
228226
a, _ := test.New(t)

pkg/applicationserver/io/packages/alcsync/v1/timesync_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ func TestTimeSynchronizationCommandCalculatesCorrection(t *testing.T) {
106106
}
107107

108108
for _, tc := range testCases {
109-
tc := tc
110109
t.Run(tc.Name, func(t *testing.T) {
111110
t.Parallel()
112111
a, _ := test.New(t)
@@ -171,7 +170,6 @@ func TestTimeSynchronizationCommandRespectsThreshold(t *testing.T) {
171170
}
172171

173172
for _, tc := range testCases {
174-
tc := tc
175173
t.Run(tc.Name, func(t *testing.T) {
176174
t.Parallel()
177175
a, _ := test.New(t)
@@ -231,7 +229,6 @@ func TestTimeSynchronizationCommandRespectsAnsRequired(t *testing.T) {
231229
}
232230

233231
for _, tc := range testCases {
234-
tc := tc
235232
t.Run(tc.Name, func(t *testing.T) {
236233
t.Parallel()
237234
a, _ := test.New(t)

pkg/applicationserver/io/packages/loragls/v3/data_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ func TestPackageDataDeserialization(t *testing.T) {
153153
}
154154

155155
for _, tc := range testCases {
156-
tc := tc
157156
t.Run(tc.Name, func(t *testing.T) {
158157
t.Parallel()
159158
data := &Data{}
@@ -219,7 +218,6 @@ func TestPackageDataSerialization(t *testing.T) {
219218
}
220219

221220
for _, tc := range testCases {
222-
tc := tc
223221
t.Run(tc.Name, func(t *testing.T) {
224222
t.Parallel()
225223

@@ -320,7 +318,6 @@ func TestPackageDataMerge(t *testing.T) {
320318
}
321319

322320
for _, tc := range testCases {
323-
tc := tc
324321
t.Run(tc.Name, func(t *testing.T) {
325322
t.Parallel()
326323

@@ -374,7 +371,6 @@ func TestPackageDataValidation(t *testing.T) {
374371
}
375372

376373
for _, tc := range testCases {
377-
tc := tc
378374
t.Run(tc.Name, func(t *testing.T) {
379375
t.Parallel()
380376

pkg/auth/rights/rights_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ func TestMap(t *testing.T) {
219219
},
220220
},
221221
} {
222-
tc := tc
223222
t.Run(tc.Name, func(t *testing.T) {
224223
t.Parallel()
225224
a.So(tc.Assertion(t, tc.Rights, tc.NewMap(t, tc.Rights)), should.BeTrue)

pkg/band/band_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,7 +1426,6 @@ func TestGenerateChMask(t *testing.T) {
14261426
},
14271427
},
14281428
} {
1429-
tc := tc
14301429
t.Run(tc.Name, func(t *testing.T) {
14311430
t.Parallel()
14321431
a := assertions.New(t)
@@ -1542,7 +1541,6 @@ func TestCompareDatarates(t *testing.T) {
15421541
Expected: false,
15431542
},
15441543
} {
1545-
tc := tc
15461544
t.Run(tc.Name, func(t *testing.T) {
15471545
t.Parallel()
15481546

@@ -1832,7 +1830,6 @@ func TestChannelsWellDefined(t *testing.T) {
18321830

18331831
for name, versions := range All {
18341832
for version, b := range versions {
1835-
b := b
18361833
t.Run(fmt.Sprintf("%v/%v", name, version), func(t *testing.T) {
18371834
t.Parallel()
18381835

@@ -1859,7 +1856,6 @@ func TestSubBandsWellDefined(t *testing.T) {
18591856

18601857
for name, versions := range All {
18611858
for version, b := range versions {
1862-
b := b
18631859
t.Run(fmt.Sprintf("%v/%v", name, version), func(t *testing.T) {
18641860
t.Parallel()
18651861

pkg/band/reference_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ func TestBandDefinitions(t *testing.T) {
235235
t.Parallel()
236236
for name, versions := range band.All {
237237
for version, b := range versions {
238-
version, b := version, b
239238
t.Run(fmt.Sprintf("%v/%v", name, version), func(t *testing.T) {
240239
t.Parallel()
241240
testBand(t, makeBand(b), version)
@@ -248,7 +247,6 @@ func TestLatest(t *testing.T) {
248247
t.Parallel()
249248

250249
for name := range band.All {
251-
name := name
252250
t.Run(name, func(t *testing.T) {
253251
t.Parallel()
254252
if _, ok := band.LatestVersion[name]; !ok {
@@ -258,7 +256,6 @@ func TestLatest(t *testing.T) {
258256
}
259257

260258
for name := range band.LatestVersion {
261-
name := name
262259
t.Run(name, func(t *testing.T) {
263260
t.Parallel()
264261
if _, ok := band.All[name]; !ok {

0 commit comments

Comments
 (0)