Skip to content

Commit 1e23b68

Browse files
authored
only the pretty formatter should skip outputing (#80)
1 parent e096b80 commit 1e23b68

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

analyze/analyze.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -282,11 +282,6 @@ func (a *Analyzer) finalizeAnalysis(ctx context.Context, inventory *scanner.Inve
282282
return err
283283
}
284284

285-
if len(report.Findings) == 0 {
286-
log.Info().Msg("No results returned by analysis")
287-
return nil
288-
}
289-
290285
err = a.Formatter.Format(ctx, report, inventory.Packages)
291286
if err != nil {
292287
return err

formatters/pretty/pretty.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package pretty
33
import (
44
"context"
55
"fmt"
6+
"github.com/rs/zerolog/log"
67
"io"
78
"os"
89
"sort"
@@ -19,6 +20,11 @@ func (f *Format) Format(ctx context.Context, report *opa.FindingsResult, package
1920
failures := map[string]int{}
2021
findings := map[string][]opa.Finding{}
2122

23+
if len(report.Findings) == 0 {
24+
log.Info().Msg("No results returned by analysis")
25+
return nil
26+
}
27+
2228
for _, finding := range report.Findings {
2329
failures[finding.RuleId]++
2430
findings[finding.RuleId] = append(findings[finding.RuleId], finding)

0 commit comments

Comments
 (0)