Skip to content

Commit e24c18c

Browse files
build(deps): bump github.com/karamaru-alpha/copyloopvar from 1.1.0 to 1.2.1 (#5307)
Co-authored-by: Fernandez Ludovic <[email protected]>
1 parent ace35f0 commit e24c18c

File tree

6 files changed

+90
-3
lines changed

6 files changed

+90
-3
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ require (
5858
github.com/jingyugao/rowserrcheck v1.1.1
5959
github.com/jjti/go-spancheck v0.6.4
6060
github.com/julz/importas v0.2.0
61-
github.com/karamaru-alpha/copyloopvar v1.1.0
61+
github.com/karamaru-alpha/copyloopvar v1.2.1
6262
github.com/kisielk/errcheck v1.8.0
6363
github.com/kkHAIKE/contextcheck v1.1.5
6464
github.com/kulti/thelper v0.6.3

go.sum

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/golinters/copyloopvar/copyloopvar_integration_test.go

+8
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,11 @@ import (
99
func TestFromTestdata(t *testing.T) {
1010
integration.RunTestdata(t)
1111
}
12+
13+
func TestFix(t *testing.T) {
14+
integration.RunFix(t)
15+
}
16+
17+
func TestFixPathPrefix(t *testing.T) {
18+
integration.RunFixPathPrefix(t)
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//golangcitest:args -Ecopyloopvar
2+
//golangcitest:expected_exitcode 0
3+
package testdata
4+
5+
import "fmt"
6+
7+
func _() {
8+
slice := []int{1, 2, 3}
9+
fns := make([]func(), 0, len(slice)*2)
10+
for i, v := range slice {
11+
i := i // want `The copy of the 'for' variable "i" can be deleted \(Go 1\.22\+\)`
12+
fns = append(fns, func() {
13+
fmt.Println(i)
14+
})
15+
v := v // want `The copy of the 'for' variable "v" can be deleted \(Go 1\.22\+\)`
16+
fns = append(fns, func() {
17+
fmt.Println(v)
18+
})
19+
_v := v
20+
_ = _v
21+
}
22+
for _, fn := range fns {
23+
fn()
24+
}
25+
}
26+
27+
func _() {
28+
loopCount := 3
29+
fns := make([]func(), 0, loopCount)
30+
for i := 1; i <= loopCount; i++ {
31+
i := i // want `The copy of the 'for' variable "i" can be deleted \(Go 1\.22\+\)`
32+
fns = append(fns, func() {
33+
fmt.Println(i)
34+
})
35+
}
36+
for _, fn := range fns {
37+
fn()
38+
}
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//golangcitest:args -Ecopyloopvar
2+
//golangcitest:expected_exitcode 0
3+
package testdata
4+
5+
import "fmt"
6+
7+
func _() {
8+
slice := []int{1, 2, 3}
9+
fns := make([]func(), 0, len(slice)*2)
10+
for i, v := range slice {
11+
// want `The copy of the 'for' variable "i" can be deleted \(Go 1\.22\+\)`
12+
fns = append(fns, func() {
13+
fmt.Println(i)
14+
})
15+
// want `The copy of the 'for' variable "v" can be deleted \(Go 1\.22\+\)`
16+
fns = append(fns, func() {
17+
fmt.Println(v)
18+
})
19+
_v := v
20+
_ = _v
21+
}
22+
for _, fn := range fns {
23+
fn()
24+
}
25+
}
26+
27+
func _() {
28+
loopCount := 3
29+
fns := make([]func(), 0, loopCount)
30+
for i := 1; i <= loopCount; i++ {
31+
// want `The copy of the 'for' variable "i" can be deleted \(Go 1\.22\+\)`
32+
fns = append(fns, func() {
33+
fmt.Println(i)
34+
})
35+
}
36+
for _, fn := range fns {
37+
fn()
38+
}
39+
}

pkg/lint/lintersdb/builder_linter.go

+1
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
181181
linter.NewConfig(copyloopvar.New(&cfg.LintersSettings.CopyLoopVar)).
182182
WithSince("v1.57.0").
183183
WithPresets(linter.PresetStyle).
184+
WithAutoFix().
184185
WithURL("https://github.com/karamaru-alpha/copyloopvar").
185186
WithNoopFallback(cfg, linter.IsGoLowerThanGo122()),
186187

0 commit comments

Comments
 (0)