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 1 commit
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
18 changes: 16 additions & 2 deletions pkg/lint/runner.go
Expand Up @@ -192,20 +192,34 @@ 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 (
linterErr error
failedLinters []string
issues []result.Issue
)

bombsimon marked this conversation as resolved.
Show resolved Hide resolved
for _, lc := range linters {
lc := lc
sw.TrackStage(lc.Name(), func() {
linterIssues, err := r.runLinterSafe(ctx, lintCtx, lc)
if err != nil {
failedLinters = append(failedLinters, lc.Linter.Name())
bombsimon marked this conversation as resolved.
Show resolved Hide resolved
r.Log.Warnf("Can't run linter %s: %v", lc.Linter.Name(), err)

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

return r.processLintResults(issues), nil
if len(failedLinters) > 0 {
linterErr = fmt.Errorf(
"one or more linters failed to run: %s",
strings.Join(failedLinters, ", "),
bombsimon marked this conversation as resolved.
Show resolved Hide resolved
)
}

return r.processLintResults(issues), linterErr
}

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