Class: RuboCop::Formatter::ClangStyleFormatter
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Subclasses:
|
|
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
SimpleTextFormatter ,
BaseFormatter
|
|
Instance Chain:
|
|
Inherits: |
RuboCop::Formatter::SimpleTextFormatter
|
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.
Constant Summary
-
ELLIPSES =
# File 'lib/rubocop/formatter/clang_style_formatter.rb', line 9'...'
::RuboCop::PathUtil
- Included
HIDDEN_FILE_PATTERN, SMART_PATH_CACHE
SimpleTextFormatter
- Inherited
Class Method Summary
BaseFormatter
- Inherited
Instance Attribute Summary
BaseFormatter
- Inherited
Instance Method Summary
- #report_file(file, offenses)
- #report_highlighted_area(highlighted_area) private
- #report_line(location) private
- #report_offense(file, offense) private
- #valid_line?(offense) ⇒ Boolean private
SimpleTextFormatter
- Inherited
#file_finished, #finished, #report_file, #report_summary, #started, #annotate_message, #colored_severity_code, #count_stats, #message |
::RuboCop::PathUtil
- Included
#absolute? | Returns true for an absolute Unix or Windows path. |
#glob? | Returns true for a glob. |
#hidden_dir?, #hidden_file?, #hidden_file_in_not_hidden_dir?, | |
#match_path? | Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity. |
#maybe_hidden_file? | Loose check to reduce memory allocations. |
#relative_path, #smart_path |
Colorizable
- Included
BaseFormatter
- Inherited
#file_finished | Invoked at the end of inspecting each files. |
#file_started | Invoked at the beginning of inspecting each files. |
#finished | Invoked after all files are inspected or interrupted by user. |
#started | Invoked once before any files are inspected. |
Constructor Details
This class inherits a constructor from RuboCop::Formatter::BaseFormatter
Instance Method Details
#report_file(file, offenses)
[ GitHub ]# File 'lib/rubocop/formatter/clang_style_formatter.rb', line 11
def report_file(file, offenses) offenses.each { |offense| report_offense(file, offense) } end
#report_highlighted_area(highlighted_area) (private)
[ GitHub ]# File 'lib/rubocop/formatter/clang_style_formatter.rb', line 47
def report_highlighted_area(highlighted_area) space_area = highlighted_area.source_buffer.slice(0...highlighted_area.begin_pos) source_area = highlighted_area.source output.puts("#{' ' * Unicode::DisplayWidth.of(space_area)}" \ "#{'^' * Unicode::DisplayWidth.of(source_area)}") end
#report_line(location) (private)
[ GitHub ]# File 'lib/rubocop/formatter/clang_style_formatter.rb', line 37
def report_line(location) source_line = location.source_line if location.single_line? output.puts(source_line) else output.puts("#{source_line} #{yellow(ELLIPSES)}") end end
#report_offense(file, offense) (private)
[ GitHub ]# File 'lib/rubocop/formatter/clang_style_formatter.rb', line 17
def report_offense(file, offense) output.printf( "%<path>s:%<line>d:%<column>d: %<severity>s: %<message>s\n", path: cyan(smart_path(file)), line: offense.line, column: offense.real_column, severity: colored_severity_code(offense), message: (offense) ) return unless valid_line?(offense) report_line(offense.location) report_highlighted_area(offense.highlighted_area) end
#valid_line?(offense) ⇒ Boolean
(private)
# File 'lib/rubocop/formatter/clang_style_formatter.rb', line 33
def valid_line?(offense) !offense.location.source_line.blank? end