Skip to content

Ensure that the Issues key in JSON format is a list #2358

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 14, 2021
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
Ensure that the Issues key in JSON format is a list
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 authored and ldez committed Nov 14, 2021
commit 1b0416b81bd510bffbd1ecd629a4d74ac8896668
3 changes: 3 additions & 0 deletions pkg/printers/json.go
Original file line number Diff line number Diff line change
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