Skip to content

Commit 628292f

Browse files
authored
Only print rules with results (#122)
1 parent 5d4c59c commit 628292f

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

formatters/pretty/pretty.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ package pretty
33
import (
44
"context"
55
"fmt"
6-
"github.com/rs/zerolog/log"
76
"io"
87
"os"
98
"sort"
109

10+
"github.com/rs/zerolog/log"
11+
1112
"github.com/boostsecurityio/poutine/models"
1213
"github.com/boostsecurityio/poutine/opa"
1314
"github.com/olekukonko/tablewriter"
@@ -45,6 +46,11 @@ func printFindingsPerRule(out io.Writer, results map[string][]opa.Finding, rules
4546
sort.Strings(sortedRuleIDs)
4647

4748
for _, ruleId := range sortedRuleIDs {
49+
// Skip rules with no findings.
50+
if len(results[ruleId]) == 0 {
51+
continue
52+
}
53+
4854
table := tablewriter.NewWriter(out)
4955
table.SetAutoMergeCells(true)
5056
table.SetHeader([]string{"Repository", "Details", "URL"})
@@ -95,11 +101,7 @@ func printFindingsPerRule(out io.Writer, results map[string][]opa.Finding, rules
95101
table.Append([]string{})
96102
}
97103

98-
if len(results[ruleId]) == 0 {
99-
fmt.Fprint(out, "\nNo findings for this repository\n")
100-
} else {
101-
table.Render()
102-
}
104+
table.Render()
103105
fmt.Fprint(out, "\n")
104106
}
105107
}

0 commit comments

Comments
 (0)