Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return error if any linter fails to run #2471

Merged
merged 3 commits into from Jan 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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