Skip to content

dev: handle linter major versions #5848

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

Merged
merged 1 commit into from
Jun 2, 2025
Merged
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
19 changes: 19 additions & 0 deletions pkg/goanalysis/linter.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,25 @@ func (lnt *Linter) WithDesc(desc string) *Linter {
return lnt
}

func (lnt *Linter) WithVersion(v int) *Linter {
if v == 0 {
return lnt
}

for _, analyzer := range lnt.analyzers {
if lnt.name != analyzer.Name {
continue
}

// The analyzer name should be the same as the linter name to avoid displaying the name inside the reports.
analyzer.Name = fmt.Sprintf("%s_v%d", analyzer.Name, v)
}

lnt.name = fmt.Sprintf("%s_v%d", lnt.name, v)

return lnt
}

func (lnt *Linter) WithConfig(cfg map[string]any) *Linter {
if len(cfg) == 0 {
return lnt
Expand Down
Loading