Class: Reek::Report::SimpleWarningFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/reek/report/simple_warning_formatter.rb

Overview

Basic formatter that just shows a simple message for each warning, prepended with the result of the passed-in location formatter.

Direct Known Subclasses

DocumentationLinkWarningFormatter

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(location_formatter: BlankLocationFormatter) ⇒ SimpleWarningFormatter

Returns a new instance of SimpleWarningFormatter.



10
11
12
# File 'lib/reek/report/simple_warning_formatter.rb', line 10

def initialize(location_formatter: BlankLocationFormatter)
  @location_formatter = location_formatter
end

Instance Attribute Details

#location_formatterObject (readonly, private)

Returns the value of attribute location_formatter.



24
25
26
# File 'lib/reek/report/simple_warning_formatter.rb', line 24

def location_formatter
  @location_formatter
end

Instance Method Details

#format(warning) ⇒ Object



14
15
16
# File 'lib/reek/report/simple_warning_formatter.rb', line 14

def format(warning)
  "#{location_formatter.format(warning)}#{warning.base_message}"
end

#format_list(warnings) ⇒ Object



18
19
20
# File 'lib/reek/report/simple_warning_formatter.rb', line 18

def format_list(warnings)
  warnings.map { |warning| "  #{format(warning)}" }.join("\n")
end