Skip to content

Commit

Permalink
exportloopref: deprecation (#4916)
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez authored Aug 17, 2024
1 parent af298e1 commit 87dd8fe
Show file tree
Hide file tree
Showing 48 changed files with 11 additions and 92 deletions.
4 changes: 3 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,16 @@ linters:
disable-all: true
enable:
- bodyclose
- copyloopvar
- depguard
- dogsled
- dupl
- errcheck
- errorlint
- exportloopref
- funlen
- gocheckcompilerdirectives
- gochecknoinits
- gochecknoinits
- goconst
- gocritic
- gocyclo
Expand All @@ -126,6 +127,7 @@ linters:
- gosec
- gosimple
- govet
- intrange
- ineffassign
- lll
- misspell
Expand Down
1 change: 0 additions & 1 deletion pkg/commands/config_verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ func printValidationDetail(cmd *cobra.Command, detail *jsonschema.Detailed) {
}

for _, d := range detail.Errors {
d := d
printValidationDetail(cmd, &d)
}
}
Expand Down
2 changes: 0 additions & 2 deletions pkg/commands/config_verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ func Test_createSchemaURL(t *testing.T) {
}

for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -126,7 +125,6 @@ func Test_createSchemaURL_error(t *testing.T) {
}

for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

Expand Down
1 change: 0 additions & 1 deletion pkg/commands/internal/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func Test_sanitizeVersion(t *testing.T) {
}

for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

Expand Down
2 changes: 0 additions & 2 deletions pkg/commands/internal/configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ func TestConfiguration_Validate(t *testing.T) {
}

for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -115,7 +114,6 @@ func TestConfiguration_Validate_error(t *testing.T) {
}

for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

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

for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -124,7 +123,6 @@ func Test_trimGoVersion(t *testing.T) {
}

for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

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

for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -194,7 +193,6 @@ func TestExcludeRule_Validate_error(t *testing.T) {
}

for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

Expand Down
6 changes: 0 additions & 6 deletions pkg/config/linters_settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ func TestLintersSettings_Validate(t *testing.T) {
}

for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -74,7 +73,6 @@ func TestLintersSettings_Validate_error(t *testing.T) {
}

for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -112,7 +110,6 @@ func TestCustomLinterSettings_Validate(t *testing.T) {
}

for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -144,7 +141,6 @@ func TestCustomLinterSettings_Validate_error(t *testing.T) {
}

for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -181,7 +177,6 @@ func TestGovetSettings_Validate(t *testing.T) {
}

for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -224,7 +219,6 @@ func TestGovetSettings_Validate_error(t *testing.T) {
}

for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

Expand Down
4 changes: 0 additions & 4 deletions pkg/config/linters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ func TestLinters_validateDisabledAndEnabledAtOneMoment(t *testing.T) {
}

for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -77,7 +76,6 @@ func TestLinters_validateDisabledAndEnabledAtOneMoment_error(t *testing.T) {
}

for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -138,7 +136,6 @@ func TestLinters_validateAllDisableEnableOptions(t *testing.T) {
}

for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -201,7 +198,6 @@ func TestLinters_validateAllDisableEnableOptions_error(t *testing.T) {
}

for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

Expand Down
4 changes: 0 additions & 4 deletions pkg/config/output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ func TestOutput_Validate(t *testing.T) {
}

for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -95,7 +94,6 @@ func TestOutput_Validate_error(t *testing.T) {
}

for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -133,7 +131,6 @@ func TestOutputFormat_Validate(t *testing.T) {
}

for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -164,7 +161,6 @@ func TestOutputFormat_Validate_error(t *testing.T) {
}

for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

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

for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

Expand All @@ -64,7 +63,6 @@ func TestRun_Validate_error(t *testing.T) {
}

for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

Expand Down
3 changes: 0 additions & 3 deletions pkg/config/severity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ func TestSeverity_Validate(t *testing.T) {
}

for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -96,7 +95,6 @@ func TestSeverity_Validate_error(t *testing.T) {
}

for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -194,7 +192,6 @@ func TestSeverityRule_Validate_error(t *testing.T) {
}

for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

Expand Down
2 changes: 0 additions & 2 deletions pkg/goanalysis/pkgerrors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ func BuildIssuesFromIllTypedError(errs []error, lintCtx *linter.Context) ([]resu
var other error

for _, err := range errs {
err := err

var ill *IllTypedError
if !errors.As(err, &ill) {
if other == nil {
Expand Down
1 change: 0 additions & 1 deletion pkg/goanalysis/pkgerrors/extract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ func Test_stackCrusher(t *testing.T) {
}

for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

Expand Down
2 changes: 1 addition & 1 deletion pkg/goanalysis/runner_loadingpackage.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ func sizeOfReflectValueTreeBytes(rv reflect.Value, visitedPtrs map[uintptr]struc
return sizeOfReflectValueTreeBytes(rv.Elem(), visitedPtrs)
case reflect.Struct:
ret := 0
for i := 0; i < rv.NumField(); i++ {
for i := range rv.NumField() {
ret += sizeOfReflectValueTreeBytes(rv.Field(i), visitedPtrs)
}
return ret
Expand Down
2 changes: 1 addition & 1 deletion pkg/goanalysis/runners.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func loadIssuesFromCache(pkgs []*packages.Package, lintCtx *linter.Context,
wg.Add(workerCount)

pkgCh := make(chan *packages.Package, len(pkgs))
for i := 0; i < workerCount; i++ {
for range workerCount {
go func() {
defer wg.Done()
for pkg := range pkgCh {
Expand Down
2 changes: 0 additions & 2 deletions pkg/golinters/gocritic/gocritic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ func Test_settingsWrapper_InferEnabledChecks(t *testing.T) {
}

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

Expand Down Expand Up @@ -434,7 +433,6 @@ func Test_settingsWrapper_Validate(t *testing.T) {
}

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

Expand Down
1 change: 0 additions & 1 deletion pkg/golinters/gosec/gosec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ func Test_toGosecConfig(t *testing.T) {
}

for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

Expand Down
1 change: 0 additions & 1 deletion pkg/golinters/internal/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ func ExtractIssuesFromPatch(patch string, lintCtx *linter.Context, linterName st
changes := p.parse(hunk)

for _, change := range changes {
change := change // fix scope
i := result.Issue{
FromLinter: linterName,
Pos: token.Position{
Expand Down
1 change: 0 additions & 1 deletion pkg/golinters/misspell/misspell_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ func Test_appendExtraWords_error(t *testing.T) {
}

for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

Expand Down
1 change: 0 additions & 1 deletion pkg/golinters/nolintlint/internal/nolintlint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ func foo() {
}

for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

Expand Down
1 change: 0 additions & 1 deletion pkg/golinters/thelper/testdata/thelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ func TestSubtestShouldNotBeChecked(t *testing.T) {
}

for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

Expand Down
3 changes: 2 additions & 1 deletion pkg/lint/lintersdb/builder_linter.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
WithSince("v1.28.0").
WithPresets(linter.PresetBugs).
WithLoadForGoAnalysis().
WithURL("https://github.com/kyoh86/exportloopref"),
WithURL("https://github.com/kyoh86/exportloopref").
DeprecatedWarning("Since Go1.22 (loopvar) this linter is no longer relevant.", "v1.60.2", "copyloopvar"),

linter.NewConfig(forbidigo.New(&cfg.LintersSettings.Forbidigo)).
WithSince("v1.34.0").
Expand Down
2 changes: 0 additions & 2 deletions pkg/lint/lintersdb/builder_plugin_go.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ func (b *PluginGoBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
continue
}

settings := settings

lc, err := b.loadConfig(cfg, name, &settings)
if err != nil {
return nil, fmt.Errorf("unable to load custom analyzer %q: %s, %w", name, settings.Path, err)
Expand Down
1 change: 0 additions & 1 deletion pkg/lint/lintersdb/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ func (m *Manager) build(enabledByDefaultLinters []*linter.Config) map[string]*li
// --presets can only add linters to default set
for _, p := range m.cfg.Linters.Presets {
for _, lc := range m.GetAllLinterConfigsForPreset(p) {
lc := lc
resultLintersSet[lc.Name()] = lc
}
}
Expand Down
2 changes: 0 additions & 2 deletions pkg/lint/lintersdb/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ func TestManager_build(t *testing.T) {
}

for _, c := range cases {
c := c
t.Run(c.name, func(t *testing.T) {
m, err := NewManager(logutils.NewStderrLog("skip"), &config.Config{Linters: c.cfg}, NewLinterBuilder())
require.NoError(t, err)
Expand Down Expand Up @@ -304,7 +303,6 @@ func TestManager_combineGoAnalysisLinters(t *testing.T) {
}

for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()

Expand Down
Loading

0 comments on commit 87dd8fe

Please sign in to comment.