Class: Reek::CLI::Command::ReportCommand

Inherits:
BaseCommand show all
Defined in:
lib/reek/cli/command/report_command.rb

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

Constructor Details

This class inherits a constructor from Reek::CLI::Command::BaseCommand

Instance Method Details

#executeObject



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

#heading_formatterObject (private)



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

#location_formatterObject (private)



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_smellsObject (private)



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

#progress_formatterObject (private)



66
67
68
# File 'lib/reek/cli/command/report_command.rb', line 66

def progress_formatter
  Report.progress_formatter(options.progress_format)
end

#report_classObject (private)



46
47
48
# File 'lib/reek/cli/command/report_command.rb', line 46

def report_class
  Report.report_class(options.report_format)
end

#reporterObject (private)



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_codeObject (private)



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_countObject (private)



70
71
72
# File 'lib/reek/cli/command/report_command.rb', line 70

def sort_by_issue_count
  options.sorting == :smelliness
end

#warning_formatterObject (private)



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

#warning_formatter_classObject (private)



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