From e56a5df4e2e80a961257b1add9ecaec6fcb6f99d Mon Sep 17 00:00:00 2001 From: weidongkl Date: Thu, 4 Dec 2025 10:16:23 +0800 Subject: [PATCH] refactor: simplify report functions in main.go - 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 --- cmd/gosec/main.go | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/cmd/gosec/main.go b/cmd/gosec/main.go index 63e0ffd9ae..60ad20578c 100644 --- a/cmd/gosec/main.go +++ b/cmd/gosec/main.go @@ -294,11 +294,7 @@ func getPrintedFormat(format string, verbose string) string { } func printReport(format string, color bool, rootPaths []string, reportInfo *gosec.ReportInfo) error { - err := report.CreateReport(os.Stdout, format, color, rootPaths, reportInfo) - if err != nil { - return err - } - return nil + return report.CreateReport(os.Stdout, format, color, rootPaths, reportInfo) } 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 return err } defer outfile.Close() // #nosec G307 - err = report.CreateReport(outfile, format, false, rootPaths, reportInfo) - if err != nil { - return err - } - return nil + return report.CreateReport(outfile, format, false, rootPaths, reportInfo) } func convertToScore(value string) (issue.Score, error) {