Skip to content

Commit

Permalink
Ensure that the Issues key in JSON format is a list (#2358)
Browse files Browse the repository at this point in the history
This makes the data more consistent and easier to use with other tools.
For example, a third-party tool can iterate over `Issues` without having
to make a preliminary null check.
  • Loading branch information
rafikdraoui committed Nov 14, 2021
1 parent aa3550a commit e788757
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/printers/json.go
Expand Up @@ -30,6 +30,9 @@ func (p JSON) Print(ctx context.Context, issues []result.Issue) error {
Issues: issues,
Report: p.rd,
}
if res.Issues == nil {
res.Issues = []result.Issue{}
}

outputJSON, err := json.Marshal(res)
if err != nil {
Expand Down

0 comments on commit e788757

Please sign in to comment.