Skip to content

Commit 94456f8

Browse files
authored
Enable reporting errors on loopvars (#376)
1 parent c8163e2 commit 94456f8

File tree

7 files changed

+1
-19
lines changed

7 files changed

+1
-19
lines changed

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ linters:
3333
- 'bidichk'
3434
- 'bodyclose'
3535
- 'containedctx'
36-
# - 'copyloopvar' TODO: enable after everything is upgraded to Go 1.22
36+
- 'copyloopvar'
3737
- 'depguard'
3838
- 'dupword'
3939
- 'durationcheck'

cfgloader/cfgloader_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,6 @@ num_val: 2`))},
114114
}
115115

116116
for _, tc := range tests {
117-
tc := tc
118-
119117
t.Run(tc.name, func(t *testing.T) {
120118
t.Parallel()
121119

cli/flags_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,8 +663,6 @@ func TestFlagSet_Parse(t *testing.T) {
663663
"single_dash": "-",
664664
"double_dash": "--",
665665
} {
666-
dash, dashName := dash, dashName
667-
668666
t.Run(dashName+"/"+tc.name, func(t *testing.T) {
669667
t.Parallel()
670668

healthcheck/healthcheck_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ func TestHandleHTTPHealth(t *testing.T) {
8484

8585
for _, tc := range cases {
8686
for _, header := range []string{"accept", "content-type"} {
87-
header := header
88-
8987
t.Run(tc.name+"_"+header, func(t *testing.T) {
9088
t.Parallel()
9189

internal/tools/terraformlinter/terraform_linter.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,6 @@ func RunLinter(ctx context.Context, paths []string) error {
106106

107107
// Process each provided path in parallel for violations.
108108
for _, path := range paths {
109-
path := path
110-
111109
if err := pool.Do(ctx, func() ([]*ViolationInstance, error) {
112110
instances, err := lint(path)
113111
if err != nil {

multicloser/multicloser_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ func TestClose(t *testing.T) {
8484

8585
var c *Closer
8686
for i := 0; i < 5; i++ {
87-
i := i
8887
c = Append(c, func() error {
8988
return fmt.Errorf("%d", i)
9089
})

workerpool/workerpool_test.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,6 @@ func TestWorker_Done(t *testing.T) {
101101
})
102102

103103
for i := 0; i < 5; i++ {
104-
i := i
105-
106104
if err := pool.Do(ctx, func() (*Void, error) {
107105
time.Sleep(time.Duration(i) * time.Millisecond)
108106
return nil, fmt.Errorf("%d", i)
@@ -137,8 +135,6 @@ func TestWorker_Done(t *testing.T) {
137135
})
138136

139137
for i := 0; i < 5; i++ {
140-
i := i
141-
142138
if err := pool.Do(ctx, func() (int, error) {
143139
time.Sleep(time.Duration(i) * time.Millisecond)
144140
return i, nil
@@ -173,8 +169,6 @@ func TestWorker_Done(t *testing.T) {
173169
})
174170

175171
for i := 0; i < 5; i++ {
176-
i := i
177-
178172
_ = pool.Do(ctx, func() (int, error) {
179173
if i < 2 {
180174
return i, nil
@@ -218,8 +212,6 @@ func TestWorker_Done(t *testing.T) {
218212
})
219213

220214
for i := 0; i < 5; i++ {
221-
i := i
222-
223215
err := pool.Do(ctx, func() (int, error) {
224216
time.Sleep(100 * time.Millisecond)
225217
return i, nil
@@ -266,7 +258,6 @@ func TestWorker_Done(t *testing.T) {
266258
var wg sync.WaitGroup
267259

268260
for i := 0; i < 15; i++ {
269-
i := i
270261
wg.Add(1)
271262

272263
go func() {

0 commit comments

Comments
 (0)