Skip to content

Commit dc501ea

Browse files
rafikdraouiSeigeC
authored andcommitted
Ensure that the Issues key in JSON format is a list (golangci#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 cfc052f commit dc501ea

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)