Class: Rubocop::Formatter::SimpleTextFormatter
Overview
A basic formatter that displays only files with offences.
Offences are displayed at compact form - just the
location of the problem and the associated message.
Constant Summary
collapse
- COLOR_FOR_SEVERITY =
{
refactor: :yellow,
convention: :yellow,
warning: :magenta,
error: :red,
fatal: :red
}.freeze
Instance Attribute Summary
#output
Instance Method Summary
collapse
#file_started, #initialize
Instance Method Details
#file_finished(file, offences) ⇒ Object
22
23
24
25
26
|
# File 'lib/rubocop/formatter/simple_text_formatter.rb', line 22
def file_finished(file, offences)
return if offences.empty?
count_stats(offences)
report_file(file, offences)
end
|
#finished(inspected_files) ⇒ Object
28
29
30
31
32
|
# File 'lib/rubocop/formatter/simple_text_formatter.rb', line 28
def finished(inspected_files)
report_summary(inspected_files.count,
@total_offence_count,
@total_correction_count)
end
|
#report_file(file, offences) ⇒ Object
34
35
36
37
38
39
40
41
42
|
# File 'lib/rubocop/formatter/simple_text_formatter.rb', line 34
def report_file(file, offences)
output.puts "== #{smart_path(file)} ==".color(:yellow)
offences.each do |o|
output.printf("%s:%3d:%3d: %s\n",
colored_severity_code(o),
o.line, o.real_column, message(o))
end
end
|
#report_summary(file_count, offence_count, correction_count) ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/rubocop/formatter/simple_text_formatter.rb', line 44
def report_summary(file_count, offence_count, correction_count)
summary = pluralize(file_count, 'file')
summary << ' inspected, '
offences_text = pluralize(offence_count, 'offence', no_for_zero: true)
offences_text << ' detected'
summary << offences_text.color(offence_count.zero? ? :green : :red)
if correction_count > 0
summary << ', '
correction_text = pluralize(correction_count, 'offence')
correction_text << ' corrected'
color = correction_count == offence_count ? :green : :cyan
summary << correction_text.color(color)
end
output.puts
output.puts summary
end
|
#started(target_files) ⇒ Object
17
18
19
20
|
# File 'lib/rubocop/formatter/simple_text_formatter.rb', line 17
def started(target_files)
@total_offence_count = 0
@total_correction_count = 0
end
|