Skip to content

exportloopref: disable linter for Go versions >= Go 1.22 #4915

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions pkg/lint/linter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,16 @@ func (lc *Config) WithNoopFallback(cfg *config.Config, cond func(cfg *config.Con
return lc
}

func IsGoGreaterThanOrEqualGo122() func(cfg *config.Config) error {
return func(cfg *config.Config) error {
if cfg == nil || !config.IsGoGreaterThanOrEqual(cfg.Run.Go, "1.22") {
return nil
}

return fmt.Errorf("this linter is disabled because the Go version (%s) of your project is greater than or equal Go 1.22", cfg.Run.Go)
}
}

func IsGoLowerThanGo122() func(cfg *config.Config) error {
return func(cfg *config.Config) error {
if cfg == nil || config.IsGoGreaterThanOrEqual(cfg.Run.Go, "1.22") {
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").
WithNoopFallback(cfg, linter.IsGoGreaterThanOrEqualGo122()),

linter.NewConfig(forbidigo.New(&cfg.LintersSettings.Forbidigo)).
WithSince("v1.34.0").
Expand Down
Loading