Skip to content

Commit 6cd10a9

Browse files
authored
dev: handle linter major versions (#5848)
1 parent f851497 commit 6cd10a9

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

pkg/goanalysis/linter.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,25 @@ func (lnt *Linter) WithDesc(desc string) *Linter {
7676
return lnt
7777
}
7878

79+
func (lnt *Linter) WithVersion(v int) *Linter {
80+
if v == 0 {
81+
return lnt
82+
}
83+
84+
for _, analyzer := range lnt.analyzers {
85+
if lnt.name != analyzer.Name {
86+
continue
87+
}
88+
89+
// The analyzer name should be the same as the linter name to avoid displaying the name inside the reports.
90+
analyzer.Name = fmt.Sprintf("%s_v%d", analyzer.Name, v)
91+
}
92+
93+
lnt.name = fmt.Sprintf("%s_v%d", lnt.name, v)
94+
95+
return lnt
96+
}
97+
7998
func (lnt *Linter) WithConfig(cfg map[string]any) *Linter {
8099
if len(cfg) == 0 {
81100
return lnt

0 commit comments

Comments
 (0)