Skip to content

Commit

Permalink
Sort the issues by severity in descending order before creating the r…
Browse files Browse the repository at this point in the history
…eport
  • Loading branch information
ccojocar committed Feb 8, 2018
1 parent 6b28d5c commit d4ebb03
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cmd/gas/main.go
Expand Up @@ -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
)

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit d4ebb03

Please sign in to comment.