Skip to content

Commit

Permalink
fix hangup of golangci-lint on large projects with compilation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jirfag committed Nov 10, 2018
1 parent ac77eaa commit 952cc0b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 1 addition & 5 deletions pkg/lint/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions pkg/packages/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 952cc0b

Please sign in to comment.