Skip to content

Commit f3e349f

Browse files
saschagrunerttpounds
authored andcommitted
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 <[email protected]>
1 parent ae427c1 commit f3e349f

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

pkg/commands/run.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,11 @@ func (e *Executor) runAnalysis(ctx context.Context, args []string) ([]result.Iss
315315
return nil, err
316316
}
317317

318-
issues := runner.Run(ctx, enabledLinters, lintCtx)
318+
issues, err := runner.Run(ctx, enabledLinters, lintCtx)
319+
if err != nil {
320+
return nil, err
321+
}
322+
319323
fixer := processors.NewFixer(e.cfg, e.log, e.fileCache)
320324
return fixer.Process(issues), nil
321325
}

pkg/lint/runner.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -175,24 +175,26 @@ func (r Runner) printPerProcessorStat(stat map[string]processorStat) {
175175
}
176176
}
177177

178-
func (r Runner) Run(ctx context.Context, linters []*linter.Config, lintCtx *linter.Context) []result.Issue {
178+
func (r Runner) Run(ctx context.Context, linters []*linter.Config, lintCtx *linter.Context) ([]result.Issue, error) {
179179
sw := timeutils.NewStopwatch("linters", r.Log)
180180
defer sw.Print()
181181

182182
var issues []result.Issue
183+
var runErr error
183184
for _, lc := range linters {
184185
lc := lc
185186
sw.TrackStage(lc.Name(), func() {
186187
linterIssues, err := r.runLinterSafe(ctx, lintCtx, lc)
187188
if err != nil {
188189
r.Log.Warnf("Can't run linter %s: %s", lc.Linter.Name(), err)
190+
runErr = err
189191
return
190192
}
191193
issues = append(issues, linterIssues...)
192194
})
193195
}
194196

195-
return r.processLintResults(issues)
197+
return r.processLintResults(issues), runErr
196198
}
197199

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

0 commit comments

Comments
 (0)