fix hangup of golangci-lint on large projects with compilation errors
This commit is contained in:
parent
ac77eaac68
commit
952cc0b22e
@ -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)
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user