Skip to content

Commit

Permalink
fix: sort the report by filename
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsimonemms committed Apr 4, 2024
1 parent 3ac760f commit a409c1d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/output/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package output
import (
"fmt"
"os"
"sort"

"github.com/mrsimonemms/toodaloo/pkg/scanner"
)
Expand All @@ -40,6 +41,17 @@ func Generate(reportType, savePath string, report []scanner.Report) error {
return fmt.Errorf("unknown output type: %s", reportType)
}

sort.SliceStable(report, func(i, j int) bool {
reportI := report[i]
reportJ := report[j]

if reportI.File == reportJ.File {
return reportI.LineNumber < reportJ.LineNumber
}

return reportI.File < reportJ.File
})

output, err := r.generate(report)
if err != nil {
return err
Expand Down

0 comments on commit a409c1d

Please sign in to comment.