diff --git a/.golangci.yml b/.golangci.yml index 7c21a62424cb..381d97c8d32a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -106,15 +106,16 @@ linters: disable-all: true enable: - bodyclose + - copyloopvar - depguard - dogsled - dupl - errcheck - errorlint - - exportloopref - funlen - gocheckcompilerdirectives - gochecknoinits + - gochecknoinits - goconst - gocritic - gocyclo @@ -126,6 +127,7 @@ linters: - gosec - gosimple - govet + - intrange - ineffassign - lll - misspell diff --git a/pkg/commands/config_verify.go b/pkg/commands/config_verify.go index a44050b593b3..89017e9bfc07 100644 --- a/pkg/commands/config_verify.go +++ b/pkg/commands/config_verify.go @@ -140,7 +140,6 @@ func printValidationDetail(cmd *cobra.Command, detail *jsonschema.Detailed) { } for _, d := range detail.Errors { - d := d printValidationDetail(cmd, &d) } } diff --git a/pkg/commands/config_verify_test.go b/pkg/commands/config_verify_test.go index 81d16e283298..cf62e2f9772e 100644 --- a/pkg/commands/config_verify_test.go +++ b/pkg/commands/config_verify_test.go @@ -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() @@ -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() diff --git a/pkg/commands/internal/builder_test.go b/pkg/commands/internal/builder_test.go index 508755cf2271..99a1cad0e0c1 100644 --- a/pkg/commands/internal/builder_test.go +++ b/pkg/commands/internal/builder_test.go @@ -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() diff --git a/pkg/commands/internal/configuration_test.go b/pkg/commands/internal/configuration_test.go index 3c85a9075f52..915564e1b0d7 100644 --- a/pkg/commands/internal/configuration_test.go +++ b/pkg/commands/internal/configuration_test.go @@ -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() @@ -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() diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 0fe1855cc19e..e56e6f775d91 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -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() @@ -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() diff --git a/pkg/config/issues_test.go b/pkg/config/issues_test.go index 9d590ea85e57..8470fad6ba58 100644 --- a/pkg/config/issues_test.go +++ b/pkg/config/issues_test.go @@ -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() @@ -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() diff --git a/pkg/config/linters_settings_test.go b/pkg/config/linters_settings_test.go index 1fd77d2e2215..6eed1bed450c 100644 --- a/pkg/config/linters_settings_test.go +++ b/pkg/config/linters_settings_test.go @@ -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() @@ -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() @@ -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() @@ -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() @@ -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() @@ -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() diff --git a/pkg/config/linters_test.go b/pkg/config/linters_test.go index 5be75600541f..7b01ebee60da 100644 --- a/pkg/config/linters_test.go +++ b/pkg/config/linters_test.go @@ -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() @@ -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() @@ -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() @@ -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() diff --git a/pkg/config/output_test.go b/pkg/config/output_test.go index d56342defb48..0379cfc44b76 100644 --- a/pkg/config/output_test.go +++ b/pkg/config/output_test.go @@ -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() @@ -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() @@ -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() @@ -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() diff --git a/pkg/config/run_test.go b/pkg/config/run_test.go index 7d08509ce0ab..0cf283a1ef81 100644 --- a/pkg/config/run_test.go +++ b/pkg/config/run_test.go @@ -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() @@ -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() diff --git a/pkg/config/severity_test.go b/pkg/config/severity_test.go index 049fd1663a8b..56dab604c93c 100644 --- a/pkg/config/severity_test.go +++ b/pkg/config/severity_test.go @@ -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() @@ -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() @@ -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() diff --git a/pkg/goanalysis/pkgerrors/errors.go b/pkg/goanalysis/pkgerrors/errors.go index 91f6dd39d755..7da659e80376 100644 --- a/pkg/goanalysis/pkgerrors/errors.go +++ b/pkg/goanalysis/pkgerrors/errors.go @@ -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 { diff --git a/pkg/goanalysis/pkgerrors/extract_test.go b/pkg/goanalysis/pkgerrors/extract_test.go index 1e014ea45e8e..02c801e0b106 100644 --- a/pkg/goanalysis/pkgerrors/extract_test.go +++ b/pkg/goanalysis/pkgerrors/extract_test.go @@ -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() diff --git a/pkg/goanalysis/runner_loadingpackage.go b/pkg/goanalysis/runner_loadingpackage.go index ad546fcc756f..f0ffd4cb10fa 100644 --- a/pkg/goanalysis/runner_loadingpackage.go +++ b/pkg/goanalysis/runner_loadingpackage.go @@ -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 diff --git a/pkg/goanalysis/runners.go b/pkg/goanalysis/runners.go index c02d33b79757..58777ed0e41e 100644 --- a/pkg/goanalysis/runners.go +++ b/pkg/goanalysis/runners.go @@ -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 { diff --git a/pkg/golinters/gocritic/gocritic_test.go b/pkg/golinters/gocritic/gocritic_test.go index 2a8d6088ead0..3fbcfef023a4 100644 --- a/pkg/golinters/gocritic/gocritic_test.go +++ b/pkg/golinters/gocritic/gocritic_test.go @@ -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() @@ -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() diff --git a/pkg/golinters/gosec/gosec_test.go b/pkg/golinters/gosec/gosec_test.go index e8d6187e350d..5535339a7c0b 100644 --- a/pkg/golinters/gosec/gosec_test.go +++ b/pkg/golinters/gosec/gosec_test.go @@ -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() diff --git a/pkg/golinters/internal/diff.go b/pkg/golinters/internal/diff.go index b20230dfa9cf..f919c5b2a8f2 100644 --- a/pkg/golinters/internal/diff.go +++ b/pkg/golinters/internal/diff.go @@ -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{ diff --git a/pkg/golinters/misspell/misspell_test.go b/pkg/golinters/misspell/misspell_test.go index 3766d1799224..33cd2ad82004 100644 --- a/pkg/golinters/misspell/misspell_test.go +++ b/pkg/golinters/misspell/misspell_test.go @@ -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() diff --git a/pkg/golinters/nolintlint/internal/nolintlint_test.go b/pkg/golinters/nolintlint/internal/nolintlint_test.go index 1c6d7d89b03f..0fff159285bd 100644 --- a/pkg/golinters/nolintlint/internal/nolintlint_test.go +++ b/pkg/golinters/nolintlint/internal/nolintlint_test.go @@ -209,7 +209,6 @@ func foo() { } for _, test := range testCases { - test := test t.Run(test.desc, func(t *testing.T) { t.Parallel() diff --git a/pkg/golinters/thelper/testdata/thelper.go b/pkg/golinters/thelper/testdata/thelper.go index 6458ab2dc4b8..fa6737a5a91f 100644 --- a/pkg/golinters/thelper/testdata/thelper.go +++ b/pkg/golinters/thelper/testdata/thelper.go @@ -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() diff --git a/pkg/lint/lintersdb/builder_linter.go b/pkg/lint/lintersdb/builder_linter.go index 3a46cbf88e5e..2e6c148e329c 100644 --- a/pkg/lint/lintersdb/builder_linter.go +++ b/pkg/lint/lintersdb/builder_linter.go @@ -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"). diff --git a/pkg/lint/lintersdb/builder_plugin_go.go b/pkg/lint/lintersdb/builder_plugin_go.go index c6dbaf79307d..88f3e2ae3992 100644 --- a/pkg/lint/lintersdb/builder_plugin_go.go +++ b/pkg/lint/lintersdb/builder_plugin_go.go @@ -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) diff --git a/pkg/lint/lintersdb/manager.go b/pkg/lint/lintersdb/manager.go index 0a487be92e73..75ab53d7cfbb 100644 --- a/pkg/lint/lintersdb/manager.go +++ b/pkg/lint/lintersdb/manager.go @@ -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 } } diff --git a/pkg/lint/lintersdb/manager_test.go b/pkg/lint/lintersdb/manager_test.go index 227a0ca6a838..b3b6892443ea 100644 --- a/pkg/lint/lintersdb/manager_test.go +++ b/pkg/lint/lintersdb/manager_test.go @@ -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) @@ -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() diff --git a/pkg/lint/lintersdb/validator_test.go b/pkg/lint/lintersdb/validator_test.go index d9e36760860e..25e77e4490b0 100644 --- a/pkg/lint/lintersdb/validator_test.go +++ b/pkg/lint/lintersdb/validator_test.go @@ -118,7 +118,6 @@ func TestValidator_Validate(t *testing.T) { testCases = append(testCases, validatePresetsTestCases...) for _, test := range testCases { - test := test t.Run(test.desc, func(t *testing.T) { t.Parallel() @@ -139,7 +138,6 @@ func TestValidator_Validate_error(t *testing.T) { testCases = append(testCases, validatePresetsErrorTestCases...) for _, test := range testCases { - test := test t.Run(test.desc, func(t *testing.T) { t.Parallel() @@ -158,7 +156,6 @@ func TestValidator_validateLintersNames(t *testing.T) { v := NewValidator(m) for _, test := range validateLintersNamesTestCases { - test := test t.Run(test.desc, func(t *testing.T) { t.Parallel() @@ -175,7 +172,6 @@ func TestValidator_validateLintersNames_error(t *testing.T) { v := NewValidator(m) for _, test := range validateLintersNamesErrorTestCases { - test := test t.Run(test.desc, func(t *testing.T) { t.Parallel() @@ -191,7 +187,6 @@ func TestValidator_validatePresets(t *testing.T) { v := NewValidator(nil) for _, test := range validatePresetsTestCases { - test := test t.Run(test.desc, func(t *testing.T) { t.Parallel() @@ -205,7 +200,6 @@ func TestValidator_validatePresets_error(t *testing.T) { v := NewValidator(nil) for _, test := range validatePresetsErrorTestCases { - test := test t.Run(test.desc, func(t *testing.T) { t.Parallel() diff --git a/pkg/lint/package_test.go b/pkg/lint/package_test.go index 19ed1dd52beb..02778146bde5 100644 --- a/pkg/lint/package_test.go +++ b/pkg/lint/package_test.go @@ -37,7 +37,6 @@ func Test_buildArgs(t *testing.T) { } for _, test := range testCases { - test := test t.Run(test.desc, func(t *testing.T) { t.Parallel() diff --git a/pkg/lint/runner.go b/pkg/lint/runner.go index 379508ab08e4..c3b983ff6a4a 100644 --- a/pkg/lint/runner.go +++ b/pkg/lint/runner.go @@ -115,7 +115,6 @@ func (r *Runner) Run(ctx context.Context, linters []*linter.Config) ([]result.Is ) for _, lc := range linters { - lc := lc sw.TrackStage(lc.Name(), func() { linterIssues, err := r.runLinterSafe(ctx, r.lintCtx, lc) if err != nil { @@ -189,7 +188,6 @@ func (r *Runner) processLintResults(inIssues []result.Issue) []result.Issue { // finalize processors: logging, clearing, no heavy work here for _, p := range r.Processors { - p := p sw.TrackStage(p.Name(), func() { p.Finish() }) @@ -220,7 +218,6 @@ func (r *Runner) processIssues(issues []result.Issue, sw *timeutils.Stopwatch, s for _, p := range r.Processors { var newIssues []result.Issue var err error - p := p sw.TrackStage(p.Name(), func() { newIssues, err = p.Process(issues) }) diff --git a/pkg/printers/printer_test.go b/pkg/printers/printer_test.go index 2cb21bc7e837..56d0c6f92980 100644 --- a/pkg/printers/printer_test.go +++ b/pkg/printers/printer_test.go @@ -64,7 +64,6 @@ func TestPrinter_Print_stdout(t *testing.T) { } for _, test := range testCases { - test := test t.Run(test.desc, func(t *testing.T) { t.Parallel() diff --git a/pkg/printers/tab_test.go b/pkg/printers/tab_test.go index 00e376ef06dc..fbd5dca6c65b 100644 --- a/pkg/printers/tab_test.go +++ b/pkg/printers/tab_test.go @@ -82,7 +82,6 @@ path/to/fileb.go:300:9 another issue } for _, test := range testCases { - test := test t.Run(test.desc, func(t *testing.T) { t.Parallel() diff --git a/pkg/printers/text_test.go b/pkg/printers/text_test.go index fe9c53098576..bec16f72618a 100644 --- a/pkg/printers/text_test.go +++ b/pkg/printers/text_test.go @@ -110,7 +110,6 @@ path/to/fileb.go:300:9: another issue } for _, test := range testCases { - test := test t.Run(test.desc, func(t *testing.T) { t.Parallel() diff --git a/pkg/result/processors/autogenerated_exclude_test.go b/pkg/result/processors/autogenerated_exclude_test.go index 4d5468d565e0..f0325560d697 100644 --- a/pkg/result/processors/autogenerated_exclude_test.go +++ b/pkg/result/processors/autogenerated_exclude_test.go @@ -45,7 +45,6 @@ func TestAutogeneratedExclude_isGeneratedFileLax_generated(t *testing.T) { } for _, comment := range comments { - comment := comment t.Run(comment, func(t *testing.T) { t.Parallel() @@ -64,7 +63,6 @@ func TestAutogeneratedExclude_isGeneratedFileLax_nonGenerated(t *testing.T) { } for _, comment := range comments { - comment := comment t.Run(comment, func(t *testing.T) { t.Parallel() @@ -95,7 +93,6 @@ func TestAutogeneratedExclude_isGeneratedFileStrict(t *testing.T) { } for _, test := range testCases { - test := test t.Run(test.desc, func(t *testing.T) { t.Parallel() @@ -183,7 +180,6 @@ func Test_shouldPassIssue(t *testing.T) { } for _, test := range testCases { - test := test t.Run(test.desc, func(t *testing.T) { t.Parallel() @@ -236,7 +232,6 @@ func Test_shouldPassIssue_error(t *testing.T) { } for _, test := range testCases { - test := test t.Run(test.desc, func(t *testing.T) { t.Parallel() diff --git a/pkg/result/processors/exclude_rules.go b/pkg/result/processors/exclude_rules.go index b468c510137d..bf255ae82f50 100644 --- a/pkg/result/processors/exclude_rules.go +++ b/pkg/result/processors/exclude_rules.go @@ -64,7 +64,6 @@ func (p ExcludeRules) Process(issues []result.Issue) ([]result.Issue, error) { return filterIssues(issues, func(issue *result.Issue) bool { for _, rule := range p.rules { - rule := rule if rule.match(issue, p.files, p.log) { return false } diff --git a/pkg/result/processors/invalid_issue_test.go b/pkg/result/processors/invalid_issue_test.go index b0e45998041e..1af60cbf44c4 100644 --- a/pkg/result/processors/invalid_issue_test.go +++ b/pkg/result/processors/invalid_issue_test.go @@ -111,7 +111,6 @@ func TestInvalidIssue_Process(t *testing.T) { } for _, test := range testCases { - test := test t.Run(test.desc, func(t *testing.T) { t.Parallel() diff --git a/pkg/result/processors/nolint_test.go b/pkg/result/processors/nolint_test.go index b075ef618361..afe1a286ff11 100644 --- a/pkg/result/processors/nolint_test.go +++ b/pkg/result/processors/nolint_test.go @@ -183,7 +183,6 @@ func TestNolintInvalidLinterNameWithViolationOnTheSameLine(t *testing.T) { func TestNolintAliases(t *testing.T) { p := newTestNolintProcessor(getMockLog()) for _, line := range []int{47, 49, 51} { - line := line t.Run(fmt.Sprintf("line-%d", line), func(t *testing.T) { processAssertEmpty(t, p, newNolintFileIssue(line, "gosec")) }) diff --git a/pkg/result/processors/severity_test.go b/pkg/result/processors/severity_test.go index 5ae320b6626d..73b980f6c613 100644 --- a/pkg/result/processors/severity_test.go +++ b/pkg/result/processors/severity_test.go @@ -483,7 +483,6 @@ func TestSeverity_transform(t *testing.T) { } for _, test := range testCases { - test := test t.Run(test.desc, func(t *testing.T) { t.Parallel() diff --git a/pkg/result/processors/skip_dirs_test.go b/pkg/result/processors/skip_dirs_test.go index 24450d983924..7a71754c6aa7 100644 --- a/pkg/result/processors/skip_dirs_test.go +++ b/pkg/result/processors/skip_dirs_test.go @@ -48,7 +48,6 @@ func Test_absDirs(t *testing.T) { } for _, test := range testCases { - test := test t.Run(test.desc, func(t *testing.T) { t.Parallel() diff --git a/pkg/result/processors/sort_results.go b/pkg/result/processors/sort_results.go index 77f58c03e57c..4da73c72ea39 100644 --- a/pkg/result/processors/sort_results.go +++ b/pkg/result/processors/sort_results.go @@ -194,7 +194,7 @@ func mergeComparators(cmps []*comparator) (*comparator, error) { return nil, errors.New("no comparator") } - for i := 0; i < len(cmps)-1; i++ { + for i := range len(cmps) - 1 { findComparatorTip(cmps[i]).SetNext(cmps[i+1]) } diff --git a/pkg/result/processors/sort_results_test.go b/pkg/result/processors/sort_results_test.go index 46e8e76f1458..cc5b32ace543 100644 --- a/pkg/result/processors/sort_results_test.go +++ b/pkg/result/processors/sort_results_test.go @@ -79,8 +79,7 @@ type compareTestCase struct { func testCompareValues(t *testing.T, cmp *comparator, name string, tests []compareTestCase) { t.Parallel() - for i := 0; i < len(tests); i++ { - test := tests[i] + for i, test := range tests { //nolint:gocritic // To ignore rangeValCopy rule t.Run(fmt.Sprintf("%s(%d)", name, i), func(t *testing.T) { res := cmp.Compare(&test.a, &test.b) assert.Equal(t, test.expected.String(), res.String()) @@ -200,8 +199,7 @@ func TestNumericCompare(t *testing.T) { t.Parallel() - for i := 0; i < len(tests); i++ { - test := tests[i] + for i, test := range tests { t.Run(fmt.Sprintf("%s(%d)", "Numeric Compare", i), func(t *testing.T) { res := numericCompare(test.a, test.b) assert.Equal(t, test.expected.String(), res.String()) @@ -267,7 +265,6 @@ func Test_mergeComparators(t *testing.T) { } for _, test := range testCases { - test := test t.Run(test.desc, func(t *testing.T) { t.Parallel() diff --git a/scripts/website/expand_templates/linters.go b/scripts/website/expand_templates/linters.go index 465f35e4b101..1213dc45edc3 100644 --- a/scripts/website/expand_templates/linters.go +++ b/scripts/website/expand_templates/linters.go @@ -154,7 +154,7 @@ func formatDesc(desc string) string { func hasSettings(name string) bool { tp := reflect.TypeOf(config.LintersSettings{}) - for i := 0; i < tp.NumField(); i++ { + for i := range tp.NumField() { if strings.EqualFold(name, tp.Field(i).Name) { return true } diff --git a/test/enabled_linters_test.go b/test/enabled_linters_test.go index 0de10a5a6037..2121641bd101 100644 --- a/test/enabled_linters_test.go +++ b/test/enabled_linters_test.go @@ -114,7 +114,6 @@ func TestEnabledLinters(t *testing.T) { binPath := testshared.InstallGolangciLint(t) for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/test/run_test.go b/test/run_test.go index dd15f189054e..4c05402a3be5 100644 --- a/test/run_test.go +++ b/test/run_test.go @@ -144,7 +144,6 @@ func TestCgoWithIssues(t *testing.T) { } for _, test := range testCases { - test := test t.Run(test.desc, func(t *testing.T) { t.Parallel() @@ -242,7 +241,6 @@ func TestLineDirective(t *testing.T) { } for _, test := range testCases { - test := test t.Run(test.desc, func(t *testing.T) { t.Parallel() @@ -301,7 +299,6 @@ func TestLineDirectiveProcessedFiles(t *testing.T) { } for _, test := range testCases { - test := test t.Run(test.desc, func(t *testing.T) { t.Parallel() @@ -349,7 +346,6 @@ func TestSortedResults(t *testing.T) { binPath := testshared.InstallGolangciLint(t) for _, test := range testCases { - test := test t.Run(test.opt, func(t *testing.T) { t.Parallel() @@ -437,7 +433,6 @@ func TestConfigFileIsDetected(t *testing.T) { } for _, test := range testCases { - test := test t.Run(test.desc, func(t *testing.T) { t.Parallel() @@ -475,7 +470,6 @@ func TestEnableAllFastAndEnableCanCoexist(t *testing.T) { } for _, test := range testCases { - test := test t.Run(test.desc, func(t *testing.T) { t.Parallel() @@ -559,7 +553,6 @@ func TestPathPrefix(t *testing.T) { binPath := testshared.InstallGolangciLint(t) for _, test := range testCases { - test := test t.Run(test.desc, func(t *testing.T) { testshared.NewRunnerBuilder(t). WithArgs(test.args...). diff --git a/test/testshared/analysis_test.go b/test/testshared/analysis_test.go index 7446b041c2f7..52541ff3274b 100644 --- a/test/testshared/analysis_test.go +++ b/test/testshared/analysis_test.go @@ -124,7 +124,6 @@ func println(...interface{}) { println() } // want println:"found" "call of prin } for _, test := range testCases { - test := test t.Run(test.filename, func(t *testing.T) { t.Parallel() diff --git a/test/testshared/directives_test.go b/test/testshared/directives_test.go index 2f8ec6c3291e..9b52ac97ac0a 100644 --- a/test/testshared/directives_test.go +++ b/test/testshared/directives_test.go @@ -72,7 +72,6 @@ func Test_evaluateBuildTags(t *testing.T) { } for _, test := range testCases { - test := test t.Run(test.desc, func(t *testing.T) { t.Parallel() diff --git a/test/testshared/integration/fix.go b/test/testshared/integration/fix.go index 29d95960b2d6..ddd5c5e5ab95 100644 --- a/test/testshared/integration/fix.go +++ b/test/testshared/integration/fix.go @@ -56,8 +56,6 @@ func runFix(t *testing.T, extraArgs ...string) { sources := setupTestFix(t) for _, input := range sources { - input := input - t.Run(filepath.Base(input), func(t *testing.T) { t.Parallel() diff --git a/test/testshared/integration/run.go b/test/testshared/integration/run.go index 737bb78e5420..9b0dac15c837 100644 --- a/test/testshared/integration/run.go +++ b/test/testshared/integration/run.go @@ -42,7 +42,6 @@ func RunTestSourcesFromDir(t *testing.T, dir string) { log.SetLevel(logutils.LogLevelInfo) for _, source := range sources { - source := source t.Run(filepath.Base(source), func(subTest *testing.T) { subTest.Parallel() diff --git a/test/testshared/runner_test.go b/test/testshared/runner_test.go index 5d2b3634387d..5dcb10f26e24 100644 --- a/test/testshared/runner_test.go +++ b/test/testshared/runner_test.go @@ -167,7 +167,6 @@ func TestRunnerBuilder_Runner(t *testing.T) { } for _, test := range testCases { - test := test t.Run(test.desc, func(t *testing.T) { t.Parallel()