Skip to content

Commit

Permalink
Wait for linting tasks to start before waiting (#158)
Browse files Browse the repository at this point in the history
This fails sometimes when the waiting goroutine completes
before the linting tasks. In such cases an empty result is
returned.

Signed-off-by: Charlie Egan <[email protected]>
  • Loading branch information
charlieegan3 authored Jun 8, 2023
1 parent 131bd2c commit 562d430
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/linter/linter.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,6 @@ func (l Linter) lintWithRegoRules(ctx context.Context, input rules.Input) (repor
errCh := make(chan error)
doneCh := make(chan bool)

go func() {
wg.Wait()
doneCh <- true
}()

for _, name := range input.FileNames {
wg.Add(1)

Expand Down Expand Up @@ -280,6 +275,11 @@ func (l Linter) lintWithRegoRules(ctx context.Context, input rules.Input) (repor
}(name)
}

go func() {
wg.Wait()
doneCh <- true
}()

select {
case <-ctx.Done():
return report.Report{}, fmt.Errorf("context cancelled: %w", ctx.Err())
Expand Down

0 comments on commit 562d430

Please sign in to comment.