mirror of
https://github.com/securego/gosec.git
synced 2024-11-05 19:45:51 +00:00
Switch to sort Interface to be backward compatible with older go versions
This commit is contained in:
parent
d4ebb032a9
commit
84bfbbfd8c
2 changed files with 21 additions and 1 deletions
|
@ -236,7 +236,7 @@ func main() {
|
|||
|
||||
// Sort the issue by severity
|
||||
if *flagSortIssues {
|
||||
sort.Slice(issues, func(i, j int) bool { return (issues[i].Severity > issues[j].Severity) })
|
||||
sortIssues(issues)
|
||||
}
|
||||
|
||||
// Create output report
|
||||
|
|
20
cmd/gas/sort_issues.go
Normal file
20
cmd/gas/sort_issues.go
Normal file
|
@ -0,0 +1,20 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"sort"
|
||||
|
||||
"github.com/GoASTScanner/gas"
|
||||
)
|
||||
|
||||
type sortBySeverity []*gas.Issue
|
||||
|
||||
func (s sortBySeverity) Len() int { return len(s) }
|
||||
|
||||
func (s sortBySeverity) Less(i, j int) bool { return s[i].Severity > s[i].Severity }
|
||||
|
||||
func (s sortBySeverity) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
||||
|
||||
// sortIssues sorts the issues by severity in descending order
|
||||
func sortIssues(issues []*gas.Issue) {
|
||||
sort.Sort(sortBySeverity(issues))
|
||||
}
|
Loading…
Reference in a new issue