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.
Instance Attribute Summary collapse
#output
Instance Method Summary
collapse
#file_started, #initialize
Instance Attribute Details
#reports_summary ⇒ Object
Also known as:
reports_summary?
Returns the value of attribute reports_summary.
9
10
11
|
# File 'lib/rubocop/formatter/simple_text_formatter.rb', line 9
def reports_summary
@reports_summary
end
|
Instance Method Details
#file_finished(file, offences) ⇒ Object
16
17
18
19
20
|
# File 'lib/rubocop/formatter/simple_text_formatter.rb', line 16
def file_finished(file, offences)
return if offences.empty?
@total_offence_count += offences.count
report_file(file, offences)
end
|
#finished(inspected_files) ⇒ Object
22
23
24
25
26
|
# File 'lib/rubocop/formatter/simple_text_formatter.rb', line 22
def finished(inspected_files)
if reports_summary?
report_summary(inspected_files.count, @total_offence_count)
end
end
|
#report_file(file, offences) ⇒ Object
28
29
30
31
|
# File 'lib/rubocop/formatter/simple_text_formatter.rb', line 28
def report_file(file, offences)
output.puts "== #{smart_path(file)} ==".color(:yellow)
output.puts offences.join("\n")
end
|
#report_summary(file_count, offence_count) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/rubocop/formatter/simple_text_formatter.rb', line 33
def report_summary(file_count, offence_count)
summary = ''
plural = file_count == 0 || file_count > 1 ? 's' : ''
summary << "#{file_count} file#{plural} inspected, "
offences_string = case offence_count
when 0 then 'no offences'
when 1 then '1 offence'
else "#{offence_count} offences"
end
summary << "#{offences_string} detected"
.color(offence_count.zero? ? :green : :red)
output.puts
output.puts summary
end
|
#started(target_files) ⇒ Object
12
13
14
|
# File 'lib/rubocop/formatter/simple_text_formatter.rb', line 12
def started(target_files)
@total_offence_count = 0
end
|