From c373be6a16579e6b846d5e01ba4348b70bfc335f Mon Sep 17 00:00:00 2001 From: MSP-Greg Date: Sat, 7 Oct 2017 14:29:13 -0500 Subject: [PATCH] stats update - none stable sort --- lib/yard/cli/stats.rb | 5 +++-- spec/cli/stats_spec.rb | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/yard/cli/stats.rb b/lib/yard/cli/stats.rb index 00c3b6a45..91e4ca356 100644 --- a/lib/yard/cli/stats.rb +++ b/lib/yard/cli/stats.rb @@ -79,8 +79,9 @@ def print_undocumented_objects log.puts log.puts "Undocumented Objects:" - objects = @undoc_list.sort_by {|o| o.file.to_s } - max = objects.sort_by {|o| o.path.length }.last.path.length + # array needed for sort due to unstable sort + objects = @undoc_list.sort_by {|o| [o.file.to_s, o.path] } + max = objects.max {|a, b| a.path.length <=> b.path.length }.path.length if @compact objects.each do |object| log.puts("%-#{max}s (%s)" % [object.path, diff --git a/spec/cli/stats_spec.rb b/spec/cli/stats_spec.rb index 163ef8c14..42299bfb0 100644 --- a/spec/cli/stats_spec.rb +++ b/spec/cli/stats_spec.rb @@ -41,10 +41,10 @@ module B; end Undocumented Objects: (in file: (stdin)) -B A -A::CONST A#foo +A::CONST +B eof end @@ -69,10 +69,10 @@ def foo; end expect(@output.string).to eq <<-eof #{@main_stats} Undocumented Objects: -B ((stdin):11) A ((stdin):1) -A::CONST ((stdin):2) A#foo ((stdin):4) +A::CONST ((stdin):2) +B ((stdin):11) eof end