ソースを参照

Fix closing file in writeJson and writeSarif (#1187)

Oleksandr Redko 2 年 前
コミット
190ac977be
2 ファイル変更3 行追加0 行削除
  1. 2 0
      report/json.go
  2. 1 0
      report/sarif.go

+ 2 - 0
report/json.go

@@ -9,6 +9,8 @@ func writeJson(findings []Finding, w io.WriteCloser) error {
 	if len(findings) == 0 {
 		findings = []Finding{}
 	}
+	defer w.Close()
+
 	encoder := json.NewEncoder(w)
 	encoder.SetIndent("", " ")
 	return encoder.Encode(findings)

+ 1 - 0
report/sarif.go

@@ -14,6 +14,7 @@ func writeSarif(cfg config.Config, findings []Finding, w io.WriteCloser) error {
 		Version: "2.1.0",
 		Runs:    getRuns(cfg, findings),
 	}
+	defer w.Close()
 
 	encoder := json.NewEncoder(w)
 	encoder.SetIndent("", " ")