Propagate error when linter cannot be run

We now return an error if any linter is unable to run to
not exit on 0 in that case.

Closes #451

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
This commit is contained in:
Sascha Grunert 2019-12-17 11:21:02 +01:00 committed by Trevor Pounds
parent ae427c1eda
commit f3e349fb5c
2 changed files with 9 additions and 3 deletions

View File

@ -315,7 +315,11 @@ func (e *Executor) runAnalysis(ctx context.Context, args []string) ([]result.Iss
return nil, err
}
issues := runner.Run(ctx, enabledLinters, lintCtx)
issues, err := runner.Run(ctx, enabledLinters, lintCtx)
if err != nil {
return nil, err
}
fixer := processors.NewFixer(e.cfg, e.log, e.fileCache)
return fixer.Process(issues), nil
}

View File

@ -175,24 +175,26 @@ func (r Runner) printPerProcessorStat(stat map[string]processorStat) {
}
}
func (r Runner) Run(ctx context.Context, linters []*linter.Config, lintCtx *linter.Context) []result.Issue {
func (r Runner) Run(ctx context.Context, linters []*linter.Config, lintCtx *linter.Context) ([]result.Issue, error) {
sw := timeutils.NewStopwatch("linters", r.Log)
defer sw.Print()
var issues []result.Issue
var runErr error
for _, lc := range linters {
lc := lc
sw.TrackStage(lc.Name(), func() {
linterIssues, err := r.runLinterSafe(ctx, lintCtx, lc)
if err != nil {
r.Log.Warnf("Can't run linter %s: %s", lc.Linter.Name(), err)
runErr = err
return
}
issues = append(issues, linterIssues...)
})
}
return r.processLintResults(issues)
return r.processLintResults(issues), runErr
}
func (r *Runner) processIssues(issues []result.Issue, sw *timeutils.Stopwatch, statPerProcessor map[string]processorStat) []result.Issue {