Class: Rubocop::Formatter::ProgressFormatter
Overview
This formatter display dots for files with no offences and
letters for files with problems in the them. In the end it
appends the regular report data in the clang style format.
Constant Summary
collapse
- COLOR_FOR_SEVERITY =
{
refactor: :yellow,
convention: :yellow,
warning: :magenta,
error: :red,
fatal: :red
}
Instance Attribute Summary
#reports_summary
#output
Instance Method Summary
collapse
#report_file
#report_file, #report_summary
#file_started, #initialize
Instance Method Details
#file_finished(file, offences) ⇒ Object
24
25
26
27
28
|
# File 'lib/rubocop/formatter/progress_formatter.rb', line 24
def file_finished(file, offences)
@total_offence_count += offences.count
@offences_for_files[file] = offences unless offences.empty?
report_file_as_mark(file, offences)
end
|
#finished(inspected_files) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/rubocop/formatter/progress_formatter.rb', line 30
def finished(inspected_files)
output.puts
return unless reports_summary?
unless @offences_for_files.empty?
output.puts
output.puts 'Offences:'
output.puts
@offences_for_files.each do |file, offences|
report_file(file, offences)
end
end
report_summary(inspected_files.count, @total_offence_count)
end
|
#report_file_as_mark(file, offences) ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/rubocop/formatter/progress_formatter.rb', line 48
def report_file_as_mark(file, offences)
mark = if offences.empty?
'.'.color(:green)
else
highest_offence = offences.max do |a, b|
a.severity_level <=> b.severity_level
end
color = COLOR_FOR_SEVERITY[highest_offence.severity]
highest_offence.encode_severity.color(color)
end
output.write mark
end
|
#started(target_files) ⇒ Object
17
18
19
20
21
22
|
# File 'lib/rubocop/formatter/progress_formatter.rb', line 17
def started(target_files)
super
@offences_for_files = {}
file_phrase = target_files.count == 1 ? 'file' : 'files'
output.puts "Inspecting #{target_files.count} #{file_phrase}"
end
|