Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions formatters/pretty/pretty.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package pretty
import (
"context"
"fmt"
"github.com/rs/zerolog/log"
"io"
"os"
"sort"

"github.com/rs/zerolog/log"

"github.com/boostsecurityio/poutine/models"
"github.com/boostsecurityio/poutine/opa"
"github.com/olekukonko/tablewriter"
Expand Down Expand Up @@ -45,6 +46,11 @@ func printFindingsPerRule(out io.Writer, results map[string][]opa.Finding, rules
sort.Strings(sortedRuleIDs)

for _, ruleId := range sortedRuleIDs {
// Skip rules with no findings.
if len(results[ruleId]) == 0 {
continue
}

table := tablewriter.NewWriter(out)
table.SetAutoMergeCells(true)
table.SetHeader([]string{"Repository", "Details", "URL"})
Expand Down Expand Up @@ -95,11 +101,7 @@ func printFindingsPerRule(out io.Writer, results map[string][]opa.Finding, rules
table.Append([]string{})
}

if len(results[ruleId]) == 0 {
fmt.Fprint(out, "\nNo findings for this repository\n")
} else {
table.Render()
}
table.Render()
fmt.Fprint(out, "\n")
}
}
Expand Down