Class: RuboCop::Formatter::SimpleTextFormatter
Overview
A basic formatter that displays only files with offenses.
Offenses 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
#colorize, #rainbow
Methods included from PathUtil
hidden?, issue_deprecation_warning, match_path?, relative_path
Methods included from TextUtil
pluralize
#file_started, #initialize
Instance Method Details
#file_finished(file, offenses) ⇒ Object
27
28
29
30
31
|
# File 'lib/rubocop/formatter/simple_text_formatter.rb', line 27
def file_finished(file, offenses)
return if offenses.empty?
count_stats(offenses)
report_file(file, offenses)
end
|
#finished(inspected_files) ⇒ Object
33
34
35
36
37
|
# File 'lib/rubocop/formatter/simple_text_formatter.rb', line 33
def finished(inspected_files)
report_summary(inspected_files.count,
@total_offense_count,
@total_correction_count)
end
|
#report_file(file, offenses) ⇒ Object
39
40
41
42
43
44
45
46
47
|
# File 'lib/rubocop/formatter/simple_text_formatter.rb', line 39
def report_file(file, offenses)
output.puts yellow("== #{smart_path(file)} ==")
offenses.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, offense_count, correction_count) ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/rubocop/formatter/simple_text_formatter.rb', line 49
def report_summary(file_count, offense_count, correction_count)
summary = pluralize(file_count, 'file')
summary << ' inspected, '
offenses_text = pluralize(offense_count, 'offense', no_for_zero: true)
offenses_text << ' detected'
summary << colorize(offenses_text, offense_count.zero? ? :green : :red)
if correction_count > 0
summary << ', '
correction_text = pluralize(correction_count, 'offense')
correction_text << ' corrected'
color = correction_count == offense_count ? :green : :cyan
summary << colorize(correction_text, color)
end
output.puts
output.puts summary
end
|
#started(_target_files) ⇒ Object
22
23
24
25
|
# File 'lib/rubocop/formatter/simple_text_formatter.rb', line 22
def started(_target_files)
@total_offense_count = 0
@total_correction_count = 0
end
|