1
0
mirror of https://github.com/fzipp/gocyclo.git synced 2025-02-06 10:23:54 +00:00

use stable sort for stable tests

This commit is contained in:
Frederik Zipp 2022-06-04 06:30:00 +02:00
parent d664e74d8c
commit 0198fc9b4a
2 changed files with 3 additions and 3 deletions

View File

@ -30,9 +30,9 @@ func TestAnalyze(t *testing.T) {
},
{
[]string{"testdata/cases.go"},
`3 testdata c3default testdata/cases.go:32:1
`3 testdata c3nested testdata/cases.go:40:1
3 testdata c3default testdata/cases.go:32:1
3 testdata c3 testdata/cases.go:25:1
3 testdata c3nested testdata/cases.go:40:1
2 testdata c2multi testdata/cases.go:19:1
2 testdata c2default testdata/cases.go:12:1
2 testdata c2 testdata/cases.go:6:1

View File

@ -52,7 +52,7 @@ func (s Stats) TotalComplexity() uint64 {
func (s Stats) SortAndFilter(top, over int) Stats {
result := make(Stats, len(s))
copy(result, s)
sort.Sort(byComplexityDesc(result))
sort.Stable(byComplexityDesc(result))
for i, stat := range result {
if i == top {
return result[:i]