Skip to content

Commit 328e2b4

Browse files
committed
stats update - none stable sort
1 parent c546a8a commit 328e2b4

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

lib/yard/cli/stats.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ def print_undocumented_objects
7878
return if !@undoc_list || @undoc_list.empty?
7979
log.puts
8080
log.puts "Undocumented Objects:"
81-
82-
objects = @undoc_list.sort_by {|o| o.file.to_s }
83-
max = objects.sort_by {|o| o.path.length }.last.path.length
81+
# array needed for sort due to none stable sorting
82+
objects = @undoc_list.sort_by {|o| [o.file.to_s, o.path] }
83+
max = objects.max {|a, b| a.path.length <=> b.path.length }.path.length
8484
if @compact
8585
objects.each do |object|
8686
log.puts("%-#{max}s (%s)" % [object.path,

spec/cli/stats_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ module B; end
4141
Undocumented Objects:
4242
4343
(in file: (stdin))
44-
B
4544
A
46-
A::CONST
4745
A#foo
46+
A::CONST
47+
B
4848
eof
4949
end
5050

@@ -69,10 +69,10 @@ def foo; end
6969
expect(@output.string).to eq <<-eof
7070
#{@main_stats}
7171
Undocumented Objects:
72-
B ((stdin):11)
7372
A ((stdin):1)
74-
A::CONST ((stdin):2)
7573
A#foo ((stdin):4)
74+
A::CONST ((stdin):2)
75+
B ((stdin):11)
7676
eof
7777
end
7878

0 commit comments

Comments
 (0)