class Skunk::Command::StatusReporter
Knows how to report status for stinky files
Constants
- HEADINGS
- HEADINGS_WITHOUT_FILE
- HEADINGS_WITHOUT_FILE_WIDTH
- TEMPLATE
Attributes
analysed_modules[RW]
Public Instance Methods
update_status_message()
click to toggle source
Returns a status message with a table of all analysed_modules
and a skunk score average
# File lib/skunk/cli/commands/status_reporter.rb, line 30 def update_status_message opts = table_options.merge(headings: HEADINGS, rows: table) _ttable = Terminal::Table.new(opts) @status_message = TEMPLATE.result(binding) end
Private Instance Methods
analysed_modules_count()
click to toggle source
# File lib/skunk/cli/commands/status_reporter.rb, line 40 def analysed_modules_count @analysed_modules_count ||= non_test_modules.count end
non_test_modules()
click to toggle source
# File lib/skunk/cli/commands/status_reporter.rb, line 44 def non_test_modules @non_test_modules ||= analysed_modules.reject do |a_module| module_path = a_module.pathname.dirname.to_s module_path.start_with?("test", "spec") || module_path.end_with?("test", "spec") end end
skunk_score_average()
click to toggle source
# File lib/skunk/cli/commands/status_reporter.rb, line 67 def skunk_score_average return 0 if analysed_modules_count.zero? (total_skunk_score.to_d / analysed_modules_count).to_f.round(2) end
sorted_modules()
click to toggle source
# File lib/skunk/cli/commands/status_reporter.rb, line 55 def sorted_modules @sorted_modules ||= non_test_modules.sort_by(&:skunk_score).reverse! end
table()
click to toggle source
# File lib/skunk/cli/commands/status_reporter.rb, line 83 def table sorted_modules.map do |a_mod| [ a_mod.pathname, a_mod.skunk_score, a_mod.churn_times_cost, a_mod.churn, a_mod.cost.round(2), a_mod.coverage.round(2) ] end end
table_options()
click to toggle source
# File lib/skunk/cli/commands/status_reporter.rb, line 73 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: width } } end
total_churn_times_cost()
click to toggle source
# File lib/skunk/cli/commands/status_reporter.rb, line 63 def total_churn_times_cost non_test_modules.sum(&:churn_times_cost) end
total_skunk_score()
click to toggle source
# File lib/skunk/cli/commands/status_reporter.rb, line 59 def total_skunk_score @total_skunk_score ||= non_test_modules.sum(&:skunk_score) end
worst()
click to toggle source
# File lib/skunk/cli/commands/status_reporter.rb, line 51 def worst @worst ||= sorted_modules.first end