Sort the issues by severity in descending order before creating the report

This commit is contained in:
Cosmin Cojocar 2018-02-08 12:08:05 +01:00
parent 6b28d5c0e6
commit d4ebb032a9

View file

@ -79,6 +79,9 @@ var (
// log to file or stderr // log to file or stderr
flagLogfile = flag.String("log", "", "Log messages to file rather than 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 logger *log.Logger
) )
@ -231,6 +234,11 @@ func main() {
os.Exit(0) 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 // Create output report
if err := saveOutput(*flagOutput, *flagFormat, issues, metrics); err != nil { if err := saveOutput(*flagOutput, *flagFormat, issues, metrics); err != nil {
logger.Fatal(err) logger.Fatal(err)