Class: Rubocop::Formatter::ClangStyleFormatter

Inherits:
SimpleTextFormatter show all
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

ProgressFormatter

Instance Attribute Summary

Attributes inherited from SimpleTextFormatter

#reports_summary

Attributes inherited from BaseFormatter

#output

Instance Method Summary collapse

Methods inherited from SimpleTextFormatter

#file_finished, #finished, #report_summary, #started

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, offences) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rubocop/formatter/clang_style_formatter.rb', line 9

def report_file(file, offences)
  offences.each do |o|
    output.printf("%s:%d:%d: %s: %s\n",
                  smart_path(file).color(:cyan), o.line, o.real_column,
                  o.clang_severity, o.message)

    source_line = o.location.source_line

    unless source_line.blank?
      output.puts(source_line)
      output.puts(' ' * o.location.column +
                  '^' * o.location.column_range.count)
    end
  end
end