Class: Reek::Report::TextReport
Overview
Generates a sorted, text summary of smells in examiners
Constant Summary
Constants inherited
from BaseReport
BaseReport::NO_WARNINGS_COLOR, BaseReport::WARNINGS_COLOR
Instance Attribute Summary
Attributes inherited from BaseReport
#examiners, #heading_formatter, #progress_formatter, #sort_by_issue_count, #warning_formatter
Instance Method Summary
collapse
Methods inherited from BaseReport
#smells, #smells?
Constructor Details
#initialize(**args) ⇒ TextReport
Returns a new instance of TextReport.
14
15
16
17
18
|
# File 'lib/reek/report/text_report.rb', line 14
def initialize(**args)
super
print progress_formatter.
end
|
Instance Method Details
#add_examiner(examiner) ⇒ Object
21
22
23
24
|
# File 'lib/reek/report/text_report.rb', line 21
def add_examiner(examiner)
print progress_formatter.progress examiner
super
end
|
#display_summary ⇒ Object
40
41
42
|
# File 'lib/reek/report/text_report.rb', line 40
def display_summary
smell_summaries.each { |smell| puts smell }
end
|
#display_total_smell_count ⇒ Object
44
45
46
47
48
|
# File 'lib/reek/report/text_report.rb', line 44
def display_total_smell_count
return unless examiners.size > 1
print total_smell_count_message
end
|
#show ⇒ Object
27
28
29
30
31
32
|
# File 'lib/reek/report/text_report.rb', line 27
def show
sort_examiners if smells?
print progress_formatter.
display_summary
display_total_smell_count
end
|
#smell_summaries ⇒ Object
36
37
38
|
# File 'lib/reek/report/text_report.rb', line 36
def smell_summaries
examiners.map { |ex| summarize_single_examiner(ex) }.reject(&:empty?)
end
|
#sort_examiners ⇒ Object
59
60
61
|
# File 'lib/reek/report/text_report.rb', line 59
def sort_examiners
examiners.sort_by!(&:smells_count).reverse! if sort_by_issue_count
end
|
#summarize_single_examiner(examiner) ⇒ Object
50
51
52
53
54
55
56
57
|
# File 'lib/reek/report/text_report.rb', line 50
def summarize_single_examiner(examiner)
result = heading_formatter.(examiner)
if examiner.smelly?
formatted_list = warning_formatter.format_list(examiner.smells)
result += ":\n#{formatted_list}"
end
result
end
|
#total_smell_count_message ⇒ Object
63
64
65
66
|
# File 'lib/reek/report/text_report.rb', line 63
def total_smell_count_message
colour = smells? ? WARNINGS_COLOR : NO_WARNINGS_COLOR
Rainbow("#{total_smell_count} total warning#{total_smell_count == 1 ? '' : 's'}\n").color(colour)
end
|