@@ -36,15 +36,6 @@ type metrics struct {
3636}
3737
3838func Benchmark_linters (b * testing.B ) {
39- savedWD , err := os .Getwd ()
40- require .NoError (b , err )
41-
42- b .Cleanup (func () {
43- // Restore WD to avoid side effects when during all the benchmarks.
44- err = os .Chdir (savedWD )
45- require .NoError (b , err )
46- })
47-
4839 installGolangCILint (b )
4940
5041 repos := getAllRepositories (b )
@@ -67,8 +58,7 @@ func Benchmark_linters(b *testing.B) {
6758 // TODO(ldez): clean inside go1.25 PR
6859 _ = exec .CommandContext (context .Background (), binName , "cache" , "clean" ).Run ()
6960
70- err = os .Chdir (repo .dir )
71- require .NoErrorf (b , err , "can't chdir to %s" , repo .dir )
61+ b .Chdir (repo .dir )
7262
7363 lc := countGoLines (b )
7464
@@ -85,15 +75,6 @@ func Benchmark_linters(b *testing.B) {
8575}
8676
8777func Benchmark_golangciLint (b * testing.B ) {
88- savedWD , err := os .Getwd ()
89- require .NoError (b , err )
90-
91- b .Cleanup (func () {
92- // Restore WD to avoid side effects when during all the benchmarks.
93- err = os .Chdir (savedWD )
94- require .NoError (b , err )
95- })
96-
9778 installGolangCILint (b )
9879
9980 // TODO(ldez): clean inside go1.25 PR
@@ -117,8 +98,7 @@ func Benchmark_golangciLint(b *testing.B) {
11798
11899 for _ , c := range cases {
119100 b .Run (c .name , func (b * testing.B ) {
120- err = os .Chdir (c .dir )
121- require .NoErrorf (b , err , "can't chdir to %s" , c .dir )
101+ b .Chdir (c .dir )
122102
123103 lc := countGoLines (b )
124104
@@ -145,26 +125,26 @@ func getAllRepositories(tb testing.TB) []repo {
145125 name : "golangci/golangci-lint" ,
146126 dir : cloneGithubProject (tb , benchRoot , "golangci" , "golangci-lint" ),
147127 },
148- {
149- name : "goreleaser/goreleaser" ,
150- dir : cloneGithubProject (tb , benchRoot , "goreleaser" , "goreleaser" ),
151- },
152- {
153- name : "gohugoio/hugo" ,
154- dir : cloneGithubProject (tb , benchRoot , "gohugoio" , "hugo" ),
155- },
156- {
157- name : "pact-foundation/pact-go" , // CGO inside
158- dir : cloneGithubProject (tb , benchRoot , "pact-foundation" , "pact-go" ),
159- },
160- {
161- name : "kubernetes/kubernetes" ,
162- dir : cloneGithubProject (tb , benchRoot , "kubernetes" , "kubernetes" ),
163- },
164- {
165- name : "moby/buildkit" ,
166- dir : cloneGithubProject (tb , benchRoot , "moby" , "buildkit" ),
167- },
128+ // {
129+ // name: "goreleaser/goreleaser",
130+ // dir: cloneGithubProject(tb, benchRoot, "goreleaser", "goreleaser"),
131+ // },
132+ // {
133+ // name: "gohugoio/hugo",
134+ // dir: cloneGithubProject(tb, benchRoot, "gohugoio", "hugo"),
135+ // },
136+ // {
137+ // name: "pact-foundation/pact-go", // CGO inside
138+ // dir: cloneGithubProject(tb, benchRoot, "pact-foundation", "pact-go"),
139+ // },
140+ // {
141+ // name: "kubernetes/kubernetes",
142+ // dir: cloneGithubProject(tb, benchRoot, "kubernetes", "kubernetes"),
143+ // },
144+ // {
145+ // name: "moby/buildkit",
146+ // dir: cloneGithubProject(tb, benchRoot, "moby", "buildkit"),
147+ // },
168148 {
169149 name : "go source code" ,
170150 dir : filepath .Join (build .Default .GOROOT , "src" ),
@@ -242,9 +222,9 @@ func countGoLines(tb testing.TB) int {
242222 tb .Fatalf ("can't run go lines counter: %s" , err )
243223 }
244224
245- parts := bytes .Split (bytes .TrimSpace (out ), []byte (" " ))
225+ lineCount , _ , _ := bytes .Cut (bytes .TrimSpace (out ), []byte (" " ))
246226
247- n , err := strconv .Atoi (string (parts [ 0 ] ))
227+ n , err := strconv .Atoi (string (lineCount ))
248228 if err != nil {
249229 tb .Log (string (out ))
250230 tb .Fatalf ("can't parse go lines count: %s" , err )
@@ -399,7 +379,14 @@ func getLinterNames(tb testing.TB, fastOnly bool) []string {
399379 tb .Helper ()
400380
401381 // add linter names here if needed.
402- var excluded []string
382+ excluded := []string {
383+ "gci" , // Formatter
384+ "gofmt" , // Formatter
385+ "gofumpt" , // Formatter
386+ "goimports" , // Formatter
387+ "golines" , // Formatter
388+ "swaggo" , // Formatter
389+ }
403390
404391 linters , err := lintersdb .NewLinterBuilder ().Build (config .NewDefault ())
405392 require .NoError (tb , err )
@@ -410,6 +397,10 @@ func getLinterNames(tb testing.TB, fastOnly bool) []string {
410397 continue
411398 }
412399
400+ if lc .Internal {
401+ continue
402+ }
403+
413404 if fastOnly && lc .IsSlowLinter () {
414405 continue
415406 }
0 commit comments