@@ -2,7 +2,6 @@ package list
22
33import (
44 "encoding/json"
5- "io/ioutil"
65 "os"
76 "reflect"
87 "strings"
@@ -13,9 +12,14 @@ import (
1312
1413// Helper function to read issues from a file.
1514func ReadIssues (path string ) []issues.Issue {
16- raw , _ := ioutil .ReadFile (path )
15+ raw , err := os .ReadFile (path )
16+ if err != nil {
17+ panic (err )
18+ }
1719 var fetchedIssues []issues.Issue
18- _ = json .Unmarshal (raw , & fetchedIssues )
20+ if err := json .Unmarshal (raw , & fetchedIssues ); err != nil {
21+ panic (err )
22+ }
1923
2024 return fetchedIssues
2125}
@@ -26,8 +30,14 @@ func TestListCSV(t *testing.T) {
2630 opts .exportCSV ("./testdata/exported.csv" )
2731
2832 // read exported and test CSV files
29- exported , _ := ioutil .ReadFile ("./testdata/exported.csv" )
30- test , _ := ioutil .ReadFile ("./testdata/csv/test.csv" )
33+ exported , err := os .ReadFile ("./testdata/exported.csv" )
34+ if err != nil {
35+ t .Fatal (err )
36+ }
37+ test , err := os .ReadFile ("./testdata/csv/test.csv" )
38+ if err != nil {
39+ t .Fatal (err )
40+ }
3141
3242 // trim carriage returns
3343 got := strings .TrimSuffix (string (exported ), "\n " )
@@ -47,8 +57,14 @@ func TestListJSON(t *testing.T) {
4757 opts .exportJSON ("./testdata/exported.json" )
4858
4959 // read exported and test JSON files
50- exported , _ := ioutil .ReadFile ("./testdata/exported.json" )
51- test , _ := ioutil .ReadFile ("./testdata/json/test.json" )
60+ exported , err := os .ReadFile ("./testdata/exported.json" )
61+ if err != nil {
62+ t .Fatal (err )
63+ }
64+ test , err := os .ReadFile ("./testdata/json/test.json" )
65+ if err != nil {
66+ t .Fatal (err )
67+ }
5268
5369 // trim carriage returns
5470 got := strings .TrimSuffix (string (exported ), "\n " )
@@ -60,6 +76,7 @@ func TestListJSON(t *testing.T) {
6076 if ! reflect .DeepEqual (got , want ) {
6177 t .Errorf ("got: %v; want: %v\n " , got , want )
6278 }
79+ }
6380}
6481
6582func TestListSARIF (t * testing.T ) {
@@ -71,8 +88,8 @@ func TestListSARIF(t *testing.T) {
7188 opts .exportSARIF ("./testdata/exported.sarif" )
7289
7390 // read exported and test SARIF files
74- exported , _ := ioutil .ReadFile ("./testdata/exported.sarif" )
75- test , _ := ioutil .ReadFile ("./testdata/sarif/test.sarif" )
91+ exported , _ := os .ReadFile ("./testdata/exported.sarif" )
92+ test , _ := os .ReadFile ("./testdata/sarif/test.sarif" )
7693
7794 // trim carriage returns
7895 got := strings .TrimSuffix (string (exported ), "\n " )
@@ -94,8 +111,8 @@ func TestListSARIF(t *testing.T) {
94111 opts .exportSARIF ("./testdata/exported_multi.sarif" )
95112
96113 // read exported and test SARIF files
97- exported , _ := ioutil .ReadFile ("./testdata/exported_multi.sarif" )
98- test , _ := ioutil .ReadFile ("./testdata/sarif/test_multi.sarif" )
114+ exported , _ := os .ReadFile ("./testdata/exported_multi.sarif" )
115+ test , _ := os .ReadFile ("./testdata/sarif/test_multi.sarif" )
99116
100117 // trim carriage returns
101118 got := strings .TrimSuffix (string (exported ), "\n " )
0 commit comments