Class: Standard::Formatter

Inherits:
RuboCop::Formatter::BaseFormatter
  • Object
show all
Defined in:
lib/standard/formatter.rb

Constant Summary collapse

CALL_TO_ACTION_MESSAGE =
<<-CALL_TO_ACTION.gsub(/^ {6}/, "")
  Notice: Disagree with these rules? While StandardRB is pre-1.0.0, feel free to submit suggestions to:
    https://github.com/testdouble/standard/issues/new
CALL_TO_ACTION

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Formatter

Returns a new instance of Formatter.



11
12
13
14
15
16
17
# File 'lib/standard/formatter.rb', line 11

def initialize(*args)
  super
  @detects_fixability = DetectsFixability.new
  @header_printed_already = false
  @fix_suggestion_printed_already = false
  @any_uncorrected_offenses = false
end

Instance Method Details

#file_finished(file, offenses) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/standard/formatter.rb', line 19

def file_finished(file, offenses)
  return unless (uncorrected_offenses = offenses.reject(&:corrected?)).any?
  @any_uncorrected_offenses = true

  print_header_once
  print_fix_suggestion_once(uncorrected_offenses)

  uncorrected_offenses.each do |o|
    output.printf("  %s:%d:%d: %s\n", path_to(file), o.line, o.real_column, o.message.tr("\n", " "))
  end
end

#finished(_) ⇒ Object



31
32
33
# File 'lib/standard/formatter.rb', line 31

def finished(_)
  print_call_for_feedback if @any_uncorrected_offenses
end