Class: Reek::CLI::Command::ReportCommand
Overview
A command to collect smells from a set of sources and write them out in text report format.
Instance Attribute Summary
Attributes inherited from BaseCommand
#configuration, #options, #sources
Instance Method Summary
collapse
Methods inherited from BaseCommand
#initialize, #smell_names
Instance Method Details
#execute ⇒ Object
16
17
18
19
20
|
# File 'lib/reek/cli/command/report_command.rb', line 16
def execute
populate_reporter_with_smells
reporter.show
result_code
end
|
62
63
64
|
# File 'lib/reek/cli/command/report_command.rb', line 62
def heading_formatter
Report.heading_formatter(options.show_empty ? :verbose : :quiet)
end
|
58
59
60
|
# File 'lib/reek/cli/command/report_command.rb', line 58
def location_formatter
Report.location_formatter(options.location_format)
end
|
#populate_reporter_with_smells ⇒ Object
24
25
26
27
28
29
30
31
|
# File 'lib/reek/cli/command/report_command.rb', line 24
def populate_reporter_with_smells
sources.each do |source|
reporter.add_examiner Examiner.new(source,
filter_by_smells: smell_names,
configuration: configuration,
error_handler: LoggingErrorHandler.new)
end
end
|
66
67
68
|
# File 'lib/reek/cli/command/report_command.rb', line 66
def progress_formatter
Report.progress_formatter(options.progress_format)
end
|
#report_class ⇒ Object
46
47
48
|
# File 'lib/reek/cli/command/report_command.rb', line 46
def report_class
Report.report_class(options.report_format)
end
|
#reporter ⇒ Object
37
38
39
40
41
42
43
44
|
# File 'lib/reek/cli/command/report_command.rb', line 37
def reporter
@reporter ||=
report_class.new(
warning_formatter: warning_formatter,
sort_by_issue_count: sort_by_issue_count,
heading_formatter: heading_formatter,
progress_formatter: progress_formatter.new(sources.length))
end
|
#result_code ⇒ Object
33
34
35
|
# File 'lib/reek/cli/command/report_command.rb', line 33
def result_code
reporter.smells? ? options.failure_exit_code : options.success_exit_code
end
|
#sort_by_issue_count ⇒ Object
70
71
72
|
# File 'lib/reek/cli/command/report_command.rb', line 70
def sort_by_issue_count
options.sorting == :smelliness
end
|
50
51
52
|
# File 'lib/reek/cli/command/report_command.rb', line 50
def warning_formatter
warning_formatter_class.new(location_formatter: location_formatter)
end
|
54
55
56
|
# File 'lib/reek/cli/command/report_command.rb', line 54
def warning_formatter_class
Report.warning_formatter_class(options.show_links ? :documentation_links : :simple)
end
|