Skip to content

Commit

Permalink
Return error if any linter fails to run (golangci#2471)
Browse files Browse the repository at this point in the history
  • Loading branch information
bombsimon authored and SeigeC committed Apr 4, 2023
1 parent 4778755 commit e93d073
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/lint/runner.go
Expand Up @@ -6,6 +6,7 @@ import (
"runtime/debug"
"strings"

"github.com/hashicorp/go-multierror"
"github.com/pkg/errors"
gopackages "golang.org/x/tools/go/packages"

Expand Down Expand Up @@ -192,20 +193,26 @@ func (r Runner) Run(ctx context.Context, linters []*linter.Config, lintCtx *lint
sw := timeutils.NewStopwatch("linters", r.Log)
defer sw.Print()

var issues []result.Issue
var (
lintErrors *multierror.Error
issues []result.Issue
)

for _, lc := range linters {
lc := lc
sw.TrackStage(lc.Name(), func() {
linterIssues, err := r.runLinterSafe(ctx, lintCtx, lc)
if err != nil {
lintErrors = multierror.Append(lintErrors, fmt.Errorf("can't run linter %s: %w", lc.Linter.Name(), err))
r.Log.Warnf("Can't run linter %s: %v", lc.Linter.Name(), err)

return
}
issues = append(issues, linterIssues...)
})
}

return r.processLintResults(issues), nil
return r.processLintResults(issues), lintErrors.ErrorOrNil()
}

func (r *Runner) processIssues(issues []result.Issue, sw *timeutils.Stopwatch, statPerProcessor map[string]processorStat) []result.Issue {
Expand Down

0 comments on commit e93d073

Please sign in to comment.