Class: Reek::CLI::OptionInterpreter Private

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Input
Defined in:
lib/reek/cli/option_interpreter.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Interprets the options set from the command line

Instance Method Summary collapse

Methods included from Input

#sources

Constructor Details

#initialize(options) ⇒ OptionInterpreter

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of OptionInterpreter.



20
21
22
23
# File 'lib/reek/cli/option_interpreter.rb', line 20

def initialize(options)
  @options = options
  @argv = @options.argv
end

Instance Method Details

#heading_formatterObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



70
71
72
73
74
75
76
# File 'lib/reek/cli/option_interpreter.rb', line 70

def heading_formatter
  if @options.show_empty
    Report::HeadingFormatter::Verbose
  else
    Report::HeadingFormatter::Quiet
  end
end

#location_formatterObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



59
60
61
62
63
64
65
66
67
68
# File 'lib/reek/cli/option_interpreter.rb', line 59

def location_formatter
  case @options.location_format
  when :single_line
    Report::SingleLineLocationFormatter
  when :plain
    Report::BlankLocationFormatter
  else # :numbers
    Report::DefaultLocationFormatter
  end
end

#report_classObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

TODO: Move report type mapping into Report



35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/reek/cli/option_interpreter.rb', line 35

def report_class
  case @options.report_format
  when :yaml
    Report::YAMLReport
  when :json
    Report::JSONReport
  when :html
    Report::HTMLReport
  when :xml
    Report::XMLReport
  else # :text
    Report::TextReport
  end
end

#reporterObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



25
26
27
28
29
30
31
32
# File 'lib/reek/cli/option_interpreter.rb', line 25

def reporter
  @reporter ||=
    report_class.new(
      warning_formatter: warning_formatter,
      report_formatter: Report::Formatter,
      sort_by_issue_count: sort_by_issue_count,
      heading_formatter: heading_formatter)
end

#sort_by_issue_countObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



78
79
80
# File 'lib/reek/cli/option_interpreter.rb', line 78

def sort_by_issue_count
  @options.sorting == :smelliness
end

#warning_formatterObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



50
51
52
53
54
55
56
57
# File 'lib/reek/cli/option_interpreter.rb', line 50

def warning_formatter
  klass = if @options.show_links
            Report::WikiLinkWarningFormatter
          else
            Report::SimpleWarningFormatter
          end
  klass.new(location_formatter)
end