Skip to content

Commit d4ebb03

Browse files
committed
Sort the issues by severity in descending order before creating the report
1 parent 6b28d5c commit d4ebb03

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

cmd/gas/main.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ var (
7979
// log to file or stderr
8080
flagLogfile = flag.String("log", "", "Log messages to file rather than stderr")
8181

82+
// sort the issues by severity
83+
flagSortIssues = flag.Bool("sort", true, "Sort issues by severity")
84+
8285
logger *log.Logger
8386
)
8487

@@ -231,6 +234,11 @@ func main() {
231234
os.Exit(0)
232235
}
233236

237+
// Sort the issue by severity
238+
if *flagSortIssues {
239+
sort.Slice(issues, func(i, j int) bool { return (issues[i].Severity > issues[j].Severity) })
240+
}
241+
234242
// Create output report
235243
if err := saveOutput(*flagOutput, *flagFormat, issues, metrics); err != nil {
236244
logger.Fatal(err)

0 commit comments

Comments
 (0)