Skip to content

Commit f3089d5

Browse files
committed
golangci-lint: Add copyloopvar + autofix + manual fixes
1 parent a81e3f0 commit f3089d5

File tree

125 files changed

+1
-387
lines changed

Some content is hidden

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

125 files changed

+1
-387
lines changed

.golangci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ linters:
1010
- bodyclose
1111
- canonicalheader
1212
- contextcheck
13+
- copyloopvar
1314
- cyclop
1415
- dogsled
1516
- dupl

api/v1/group_routes_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ func TestGetGroups(t *testing.T) {
155155
})
156156
})
157157
for _, gp := range []*lib.Group{g0, g1, g2} {
158-
gp := gp
159158
t.Run(gp.Name, func(t *testing.T) {
160159
t.Parallel()
161160
rw := httptest.NewRecorder()

api/v1/metric_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ func TestNullMetricTypeJSON(t *testing.T) {
2525
t.Parallel()
2626

2727
for mt, val := range values {
28-
mt, val := mt, val
2928
t.Run(val, func(t *testing.T) {
3029
t.Parallel()
3130

@@ -39,7 +38,6 @@ func TestNullMetricTypeJSON(t *testing.T) {
3938
t.Parallel()
4039

4140
for mt, val := range values {
42-
mt, val := mt, val
4341
t.Run(val, func(t *testing.T) {
4442
t.Parallel()
4543

@@ -63,7 +61,6 @@ func TestNullValueTypeJSON(t *testing.T) {
6361
t.Parallel()
6462

6563
for mt, val := range values {
66-
mt, val := mt, val
6764
t.Run(val, func(t *testing.T) {
6865
t.Parallel()
6966

@@ -77,7 +74,6 @@ func TestNullValueTypeJSON(t *testing.T) {
7774
t.Parallel()
7875

7976
for mt, val := range values {
80-
mt, val := mt, val
8177
t.Run(val, func(t *testing.T) {
8278
t.Parallel()
8379

api/v1/setup_teardown_routes_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,6 @@ func TestSetupData(t *testing.T) {
206206
}
207207

208208
for id := range testCases {
209-
id := id
210209
t.Run(fmt.Sprintf("testcase_%d", id), func(t *testing.T) {
211210
t.Parallel()
212211
runTestCase(t, id)

api/v1/status_routes_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ func TestPatchStatus(t *testing.T) {
105105
}
106106

107107
for name, testCase := range testData {
108-
name, testCase := name, testCase
109108
t.Run(name, func(t *testing.T) {
110109
t.Parallel()
111110

cloudapi/logs_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ func TestRetry(t *testing.T) {
150150
}
151151

152152
for _, tt := range tests {
153-
tt := tt
154153
t.Run(tt.name, func(t *testing.T) {
155154
t.Parallel()
156155
var sleepRequests []time.Duration

internal/api/server_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@ func testHTTPHandler(rw http.ResponseWriter, _ *http.Request) {
2323
func TestLogger(t *testing.T) {
2424
t.Parallel()
2525
for _, method := range []string{"GET", "POST", "PUT", "PATCH"} {
26-
method := method
2726
t.Run("method="+method, func(t *testing.T) {
2827
t.Parallel()
2928
for _, path := range []string{"/", "/test", "/test/path"} {
30-
path := path
3129
t.Run("path="+path, func(t *testing.T) {
3230
t.Parallel()
3331
rw := httptest.NewRecorder()

internal/cmd/archive_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ func TestArchiveThresholds(t *testing.T) {
6969
}
7070

7171
for _, testCase := range testCases {
72-
testCase := testCase
7372
t.Run(testCase.name, func(t *testing.T) {
7473
t.Parallel()
7574

internal/cmd/config_consolidation_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,13 +580,11 @@ func TestConfigConsolidation(t *testing.T) {
580580
t.Parallel()
581581

582582
for tcNum, testCase := range getConfigConsolidationTestCases() {
583-
tcNum, testCase := tcNum, testCase
584583
subCommands := testCase.options.cmds
585584
if subCommands == nil { // handle the most common case
586585
subCommands = []string{"run", "archive", "cloud"}
587586
}
588587
for fsNum, subCmd := range subCommands {
589-
fsNum, subCmd := fsNum, subCmd
590588
t.Run(
591589
fmt.Sprintf("TestCase#%d_FlagSet#%d", tcNum, fsNum),
592590
func(t *testing.T) {

internal/cmd/config_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,9 @@ func TestConfigCmd(t *testing.T) {
6060
}
6161

6262
for _, data := range testdata {
63-
data := data
6463
t.Run(data.Name, func(t *testing.T) {
6564
t.Parallel()
6665
for _, test := range data.Tests {
67-
test := test
6866
t.Run(`"`+test.Name+`"`, func(t *testing.T) {
6967
t.Parallel()
7068
fs := configFlagSet()
@@ -104,11 +102,9 @@ func TestConfigEnv(t *testing.T) {
104102
},
105103
}
106104
for field, data := range testdata {
107-
field, data := field, data
108105
t.Run(field.Name, func(t *testing.T) {
109106
t.Parallel()
110107
for value, fn := range data {
111-
value, fn := value, fn
112108
t.Run(`"`+value+`"`, func(t *testing.T) {
113109
t.Parallel()
114110
var config Config
@@ -193,7 +189,6 @@ func TestDeriveAndValidateConfig(t *testing.T) {
193189
}
194190

195191
for _, tc := range testCases {
196-
tc := tc
197192
t.Run(tc.name, func(t *testing.T) {
198193
t.Parallel()
199194
_, err := deriveAndValidateConfig(tc.conf,
@@ -499,7 +494,6 @@ func TestLoadConfig(t *testing.T) {
499494
},
500495
}
501496
for _, tc := range testcases {
502-
tc := tc
503497
t.Run(tc.name, func(t *testing.T) {
504498
t.Parallel()
505499
l, hook := testutils.NewLoggerWithHook(t)

0 commit comments

Comments
 (0)