Skip to content

Commit 952cc0b

Browse files
committed
fix hangup of golangci-lint on large projects with compilation errors
1 parent ac77eaa commit 952cc0b

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

pkg/lint/load.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,15 +249,11 @@ func (cl ContextLoader) tryParseTestPackage(pkg *packages.Package) (name, testNa
249249
func (cl ContextLoader) filterPackages(pkgs []*packages.Package) []*packages.Package {
250250
packagesWithTests := map[string]bool{}
251251
for _, pkg := range pkgs {
252-
name, testName, isTest := cl.tryParseTestPackage(pkg)
252+
name, _, isTest := cl.tryParseTestPackage(pkg)
253253
if !isTest {
254254
continue
255255
}
256256
packagesWithTests[name] = true
257-
258-
if name != testName {
259-
cl.log.Infof("pkg ID=%s: %s != %s: %#v", pkg.ID, name, testName, pkg)
260-
}
261257
}
262258

263259
cl.debugf("package with tests: %#v", packagesWithTests)

pkg/packages/util.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ func ExtractErrors(pkg *packages.Package) []packages.Error {
3535
}
3636

3737
func extractErrorsImpl(pkg *packages.Package) []packages.Error {
38+
if !pkg.IllTyped { // otherwise it may take hours to traverse all deps many times
39+
return nil
40+
}
41+
3842
if len(pkg.Errors) != 0 {
3943
return pkg.Errors
4044
}

0 commit comments

Comments
 (0)