@@ -47,21 +47,18 @@ func runLinters(ctx context.Context, wg *sync.WaitGroup, tasksCh chan Linter, li
47
47
go func (i int ) {
48
48
defer wg .Done ()
49
49
for {
50
- select {
51
- case <- ctx .Done ():
52
- // XXX: if check it in a select with reading from tasksCh
53
- // it's possible to not enter to this case until tasksCh is empty.
54
- return
55
- default :
56
- }
57
-
58
50
select {
59
51
case <- ctx .Done ():
60
52
return
61
53
case linter , ok := <- tasksCh :
62
54
if ! ok {
63
55
return
64
56
}
57
+ if ctx .Err () != nil {
58
+ // XXX: if check it in only int a select
59
+ // it's possible to not enter to this case until tasksCh is empty.
60
+ return
61
+ }
65
62
res , lerr := runLinter (ctx , linter , lintCtx , i )
66
63
lintResultsCh <- lintRes {
67
64
linter : linter ,
@@ -84,7 +81,7 @@ func (r SimpleRunner) Run(ctx context.Context, linters []Linter, lintCtx *golint
84
81
os .Stdout , os .Stderr = devNull , devNull
85
82
86
83
lintResultsCh := make (chan lintRes , len (linters ))
87
- tasksCh := make (chan Linter , lintCtx . Cfg . Common . Concurrency )
84
+ tasksCh := make (chan Linter , len ( linters ) )
88
85
var wg sync.WaitGroup
89
86
wg .Add (lintCtx .Cfg .Common .Concurrency )
90
87
runLinters (ctx , & wg , tasksCh , lintResultsCh , lintCtx )
@@ -99,19 +96,26 @@ func (r SimpleRunner) Run(ctx context.Context, linters []Linter, lintCtx *golint
99
96
100
97
os .Stdout , os .Stderr = savedStdout , savedStderr
101
98
results := []result.Result {}
99
+ finishedN := 0
102
100
for res := range lintResultsCh {
103
101
if res .err != nil {
104
102
analytics .Log (ctx ).Warnf ("Can't run linter %s: %s" , res .linter .Name (), res .err )
105
103
continue
106
104
}
107
105
106
+ finishedN ++
108
107
if res .res == nil || len (res .res .Issues ) == 0 {
109
108
continue
110
109
}
111
110
112
111
results = append (results , * res .res )
113
112
}
114
113
114
+ if ctx .Err () != nil {
115
+ analytics .Log (ctx ).Warnf ("%d/%d linters finished: deadline exceeded: try increase it by passing --deadline option" ,
116
+ finishedN , len (linters ))
117
+ }
118
+
115
119
results , err = r .processResults (ctx , results )
116
120
if err != nil {
117
121
return nil , fmt .Errorf ("can't process results: %s" , err )
0 commit comments