lib/skunk/cli/commands/status_reporter.rb in skunk-0.3.2 vs lib/skunk/cli/commands/status_reporter.rb in skunk-0.4.0
- old
+ new
@@ -9,10 +9,12 @@
# Knows how to report status for stinky files
class StatusReporter < RubyCritic::Command::StatusReporter
attr_accessor :analysed_modules
HEADINGS = %w[file stink_score churn_times_cost churn cost coverage].freeze
+ HEADINGS_WITHOUT_FILE = HEADINGS - %w[file]
+ HEADINGS_WITHOUT_FILE_WIDTH = HEADINGS_WITHOUT_FILE.size * 15 # padding
TEMPLATE = ERB.new(<<-TEMPL
<%= _ttable %>\n
StinkScore Total: <%= total_stink_score %>
Modules Analysed: <%= analysed_modules_count %>
@@ -64,12 +66,14 @@
(total_stink_score.to_d / analysed_modules_count).to_f
end
def table_options
+ max = sorted_modules.max_by { |a_mod| a_mod.pathname.to_s.length }
+ width = max.pathname.to_s.length + HEADINGS_WITHOUT_FILE_WIDTH
{
style: {
- width: 200
+ width: width
}
}
end
def table