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.
This commit is contained in:
Rafik Draoui 2021-11-14 18:33:19 -04:00 committed by GitHub
parent aa3550ab83
commit e788757b32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -30,6 +30,9 @@ func (p JSON) Print(ctx context.Context, issues []result.Issue) error {
Issues: issues, Issues: issues,
Report: p.rd, Report: p.rd,
} }
if res.Issues == nil {
res.Issues = []result.Issue{}
}
outputJSON, err := json.Marshal(res) outputJSON, err := json.Marshal(res)
if err != nil { if err != nil {