Skip to content

Commit e788757

Browse files
authored
Ensure that the Issues key in JSON format is a list (#2358)
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.
1 parent aa3550a commit e788757

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

pkg/printers/json.go

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ func (p JSON) Print(ctx context.Context, issues []result.Issue) error {
3030
Issues: issues,
3131
Report: p.rd,
3232
}
33+
if res.Issues == nil {
34+
res.Issues = []result.Issue{}
35+
}
3336

3437
outputJSON, err := json.Marshal(res)
3538
if err != nil {

0 commit comments

Comments
 (0)