Skip to content

Commit

Permalink
only the pretty formatter should skip outputing (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
SUSTAPLE117 authored May 13, 2024
1 parent e096b80 commit 1e23b68
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 0 additions & 5 deletions analyze/analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,6 @@ func (a *Analyzer) finalizeAnalysis(ctx context.Context, inventory *scanner.Inve
return err
}

if len(report.Findings) == 0 {
log.Info().Msg("No results returned by analysis")
return nil
}

err = a.Formatter.Format(ctx, report, inventory.Packages)
if err != nil {
return err
Expand Down
6 changes: 6 additions & 0 deletions formatters/pretty/pretty.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package pretty
import (
"context"
"fmt"
"github.com/rs/zerolog/log"
"io"
"os"
"sort"
Expand All @@ -19,6 +20,11 @@ func (f *Format) Format(ctx context.Context, report *opa.FindingsResult, package
failures := map[string]int{}
findings := map[string][]opa.Finding{}

if len(report.Findings) == 0 {
log.Info().Msg("No results returned by analysis")
return nil
}

for _, finding := range report.Findings {
failures[finding.RuleId]++
findings[finding.RuleId] = append(findings[finding.RuleId], finding)
Expand Down

0 comments on commit 1e23b68

Please sign in to comment.