Skip to content

Commit e93d073

Browse files
bombsimonSeigeC
authored andcommitted
Return error if any linter fails to run (golangci#2471)
1 parent 4778755 commit e93d073

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

pkg/lint/runner.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"runtime/debug"
77
"strings"
88

9+
"github.com/hashicorp/go-multierror"
910
"github.com/pkg/errors"
1011
gopackages "golang.org/x/tools/go/packages"
1112

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

195-
var issues []result.Issue
196+
var (
197+
lintErrors *multierror.Error
198+
issues []result.Issue
199+
)
200+
196201
for _, lc := range linters {
197202
lc := lc
198203
sw.TrackStage(lc.Name(), func() {
199204
linterIssues, err := r.runLinterSafe(ctx, lintCtx, lc)
200205
if err != nil {
206+
lintErrors = multierror.Append(lintErrors, fmt.Errorf("can't run linter %s: %w", lc.Linter.Name(), err))
201207
r.Log.Warnf("Can't run linter %s: %v", lc.Linter.Name(), err)
208+
202209
return
203210
}
204211
issues = append(issues, linterIssues...)
205212
})
206213
}
207214

208-
return r.processLintResults(issues), nil
215+
return r.processLintResults(issues), lintErrors.ErrorOrNil()
209216
}
210217

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

0 commit comments

Comments
 (0)