Skip to content

Commit daccba6

Browse files
authored
refactor: simplify report functions in main.go (#1434)
- Remove redundant error handling patterns in printReport and saveReport - Directly return report.CreateReport results instead of if-else blocks - Maintain functionality while improving code readability Signed-off-by: weidongkl <[email protected]>
1 parent d4be287 commit daccba6

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

cmd/gosec/main.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -294,11 +294,7 @@ func getPrintedFormat(format string, verbose string) string {
294294
}
295295

296296
func printReport(format string, color bool, rootPaths []string, reportInfo *gosec.ReportInfo) error {
297-
err := report.CreateReport(os.Stdout, format, color, rootPaths, reportInfo)
298-
if err != nil {
299-
return err
300-
}
301-
return nil
297+
return report.CreateReport(os.Stdout, format, color, rootPaths, reportInfo)
302298
}
303299

304300
func saveReport(filename, format string, rootPaths []string, reportInfo *gosec.ReportInfo) error {
@@ -307,11 +303,7 @@ func saveReport(filename, format string, rootPaths []string, reportInfo *gosec.R
307303
return err
308304
}
309305
defer outfile.Close() // #nosec G307
310-
err = report.CreateReport(outfile, format, false, rootPaths, reportInfo)
311-
if err != nil {
312-
return err
313-
}
314-
return nil
306+
return report.CreateReport(outfile, format, false, rootPaths, reportInfo)
315307
}
316308

317309
func convertToScore(value string) (issue.Score, error) {

0 commit comments

Comments
 (0)