@@ -22,6 +22,11 @@ import (
22
22
"github.com/golangci/golangci-lint/pkg/timeutils"
23
23
)
24
24
25
+ type processorStat struct {
26
+ inCount int
27
+ outCount int
28
+ }
29
+
25
30
type Runner struct {
26
31
Processors []processors.Processor
27
32
Log logutils.Log
@@ -111,6 +116,33 @@ func NewRunner(log logutils.Log, cfg *config.Config, goenv *goutil.Env,
111
116
}, nil
112
117
}
113
118
119
+ func (r * Runner ) Run (ctx context.Context , linters []* linter.Config , lintCtx * linter.Context ) ([]result.Issue , error ) {
120
+ sw := timeutils .NewStopwatch ("linters" , r .Log )
121
+ defer sw .Print ()
122
+
123
+ var (
124
+ lintErrors error
125
+ issues []result.Issue
126
+ )
127
+
128
+ for _ , lc := range linters {
129
+ lc := lc
130
+ sw .TrackStage (lc .Name (), func () {
131
+ linterIssues , err := r .runLinterSafe (ctx , lintCtx , lc )
132
+ if err != nil {
133
+ lintErrors = errors .Join (lintErrors , fmt .Errorf ("can't run linter %s" , lc .Linter .Name ()), err )
134
+ r .Log .Warnf ("Can't run linter %s: %v" , lc .Linter .Name (), err )
135
+
136
+ return
137
+ }
138
+
139
+ issues = append (issues , linterIssues ... )
140
+ })
141
+ }
142
+
143
+ return r .processLintResults (issues ), lintErrors
144
+ }
145
+
114
146
func (r * Runner ) runLinterSafe (ctx context.Context , lintCtx * linter.Context ,
115
147
lc * linter.Config ) (ret []result.Issue , err error ) {
116
148
defer func () {
@@ -151,12 +183,7 @@ func (r *Runner) runLinterSafe(ctx context.Context, lintCtx *linter.Context,
151
183
return issues , nil
152
184
}
153
185
154
- type processorStat struct {
155
- inCount int
156
- outCount int
157
- }
158
-
159
- func (r Runner ) processLintResults (inIssues []result.Issue ) []result.Issue {
186
+ func (r * Runner ) processLintResults (inIssues []result.Issue ) []result.Issue {
160
187
sw := timeutils .NewStopwatch ("processing" , r .Log )
161
188
162
189
var issuesBefore , issuesAfter int
@@ -187,7 +214,7 @@ func (r Runner) processLintResults(inIssues []result.Issue) []result.Issue {
187
214
return outIssues
188
215
}
189
216
190
- func (r Runner ) printPerProcessorStat (stat map [string ]processorStat ) {
217
+ func (r * Runner ) printPerProcessorStat (stat map [string ]processorStat ) {
191
218
parts := make ([]string , 0 , len (stat ))
192
219
for name , ps := range stat {
193
220
if ps .inCount != 0 {
@@ -199,33 +226,6 @@ func (r Runner) printPerProcessorStat(stat map[string]processorStat) {
199
226
}
200
227
}
201
228
202
- func (r Runner ) Run (ctx context.Context , linters []* linter.Config , lintCtx * linter.Context ) ([]result.Issue , error ) {
203
- sw := timeutils .NewStopwatch ("linters" , r .Log )
204
- defer sw .Print ()
205
-
206
- var (
207
- lintErrors error
208
- issues []result.Issue
209
- )
210
-
211
- for _ , lc := range linters {
212
- lc := lc
213
- sw .TrackStage (lc .Name (), func () {
214
- linterIssues , err := r .runLinterSafe (ctx , lintCtx , lc )
215
- if err != nil {
216
- lintErrors = errors .Join (lintErrors , fmt .Errorf ("can't run linter %s" , lc .Linter .Name ()), err )
217
- r .Log .Warnf ("Can't run linter %s: %v" , lc .Linter .Name (), err )
218
-
219
- return
220
- }
221
-
222
- issues = append (issues , linterIssues ... )
223
- })
224
- }
225
-
226
- return r .processLintResults (issues ), lintErrors
227
- }
228
-
229
229
func (r * Runner ) processIssues (issues []result.Issue , sw * timeutils.Stopwatch , statPerProcessor map [string ]processorStat ) []result.Issue {
230
230
for _ , p := range r .Processors {
231
231
var newIssues []result.Issue
0 commit comments