diff --git a/cmd/gas/main.go b/cmd/gas/main.go index 80208ea..bfbe676 100644 --- a/cmd/gas/main.go +++ b/cmd/gas/main.go @@ -79,6 +79,9 @@ var ( // log to file or stderr flagLogfile = flag.String("log", "", "Log messages to file rather than stderr") + // sort the issues by severity + flagSortIssues = flag.Bool("sort", true, "Sort issues by severity") + logger *log.Logger ) @@ -231,6 +234,11 @@ func main() { os.Exit(0) } + // Sort the issue by severity + if *flagSortIssues { + sort.Slice(issues, func(i, j int) bool { return (issues[i].Severity > issues[j].Severity) }) + } + // Create output report if err := saveOutput(*flagOutput, *flagFormat, issues, metrics); err != nil { logger.Fatal(err)