4
0
Эх сурвалжийг харах

write a report regardless if leaks are present (#758)

Zachary Rice 4 жил өмнө
parent
commit
43ec22429f

+ 1 - 1
report/json.go

@@ -7,7 +7,7 @@ import (
 
 func writeJson(findings []Finding, w io.WriteCloser) error {
 	if len(findings) == 0 {
-		return nil
+		findings = []Finding{}
 	}
 	encoder := json.NewEncoder(w)
 	encoder.SetIndent("", " ")

+ 1 - 2
report/json_test.go

@@ -39,9 +39,8 @@ func TestWriteJSON(t *testing.T) {
 			}},
 		{
 
-			wantEmpty:      true,
 			testReportName: "empty",
-			expected:       filepath.Join(expectPath, "report", "this_should_not_exist.json"),
+			expected:       filepath.Join(expectPath, "report", "empty.json"),
 			findings:       []Finding{}},
 	}
 

+ 0 - 3
report/report.go

@@ -14,9 +14,6 @@ const (
 )
 
 func Write(findings []Finding, cfg config.Config, ext string, reportPath string) error {
-	if len(findings) == 0 {
-		return nil
-	}
 	file, err := os.Create(reportPath)
 	if err != nil {
 		return err

+ 1 - 0
testdata/expected/report/empty.json

@@ -0,0 +1 @@
+[]