Class: RuboCop::Formatter::ClangStyleFormatter
- Inherits:
-
SimpleTextFormatter
- Object
- BaseFormatter
- SimpleTextFormatter
- RuboCop::Formatter::ClangStyleFormatter
- Defined in:
- lib/rubocop/formatter/clang_style_formatter.rb
Overview
This formatter formats report data in clang style. The precise location of the problem is shown together with the relevant source code.
Direct Known Subclasses
Constant Summary collapse
- ELLIPSES =
Rainbow('...').yellow.freeze
Constants inherited from SimpleTextFormatter
SimpleTextFormatter::COLOR_FOR_SEVERITY
Instance Attribute Summary
Attributes inherited from BaseFormatter
Instance Method Summary collapse
Methods inherited from SimpleTextFormatter
#file_finished, #finished, #report_summary, #started
Methods included from Colorizable
Methods included from PathUtil
absolute?, hidden?, issue_deprecation_warning, match_path?, relative_path
Methods inherited from BaseFormatter
#file_finished, #file_started, #finished, #initialize, #started
Constructor Details
This class inherits a constructor from RuboCop::Formatter::BaseFormatter
Instance Method Details
#report_file(file, offenses) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rubocop/formatter/clang_style_formatter.rb', line 12 def report_file(file, offenses) offenses.each do |o| output.printf("%s:%d:%d: %s: %s\n", cyan(smart_path(file)), o.line, o.real_column, colored_severity_code(o), (o)) # rubocop:disable Lint/HandleExceptions begin location = o.location source_line = location.source_line next if source_line.blank? if location.first_line == location.last_line output.puts(source_line) else output.puts("#{source_line} #{ELLIPSES}") end output.puts("#{' ' * o.highlighted_area.begin_pos}" \ "#{'^' * o.highlighted_area.size}") rescue IndexError # range is not on a valid line; perhaps the source file is empty end # rubocop:enable Lint/HandleExceptions end end |