fix hangup of golangci-lint on large projects with compilation errors

This commit is contained in:
Denis Isaev 2018-11-10 14:32:26 +03:00
parent ac77eaac68
commit 952cc0b22e
No known key found for this signature in database
GPG Key ID: A36A0EC8E27A1A01
2 changed files with 5 additions and 5 deletions

View File

@ -249,15 +249,11 @@ func (cl ContextLoader) tryParseTestPackage(pkg *packages.Package) (name, testNa
func (cl ContextLoader) filterPackages(pkgs []*packages.Package) []*packages.Package {
packagesWithTests := map[string]bool{}
for _, pkg := range pkgs {
name, testName, isTest := cl.tryParseTestPackage(pkg)
name, _, isTest := cl.tryParseTestPackage(pkg)
if !isTest {
continue
}
packagesWithTests[name] = true
if name != testName {
cl.log.Infof("pkg ID=%s: %s != %s: %#v", pkg.ID, name, testName, pkg)
}
}
cl.debugf("package with tests: %#v", packagesWithTests)

View File

@ -35,6 +35,10 @@ func ExtractErrors(pkg *packages.Package) []packages.Error {
}
func extractErrorsImpl(pkg *packages.Package) []packages.Error {
if !pkg.IllTyped { // otherwise it may take hours to traverse all deps many times
return nil
}
if len(pkg.Errors) != 0 {
return pkg.Errors
}