Sha256: 0d04f4306631e708c11b86ba4d043449f5c9ae7130755698a7d5744c700a31e7

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

# encoding: utf-8
# frozen_string_literal: true

module RuboCop
  module Formatter
    # This formatter formats report data in clang style.
    # The precise location of the problem is shown together with the
    # relevant source code.
    class ClangStyleFormatter < SimpleTextFormatter
      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), message(o))

          source_line = o.location.source_line
          next if source_line.blank?

          output.puts(source_line)
          output.puts(highlight_line(o.location))
        end
      end

      def highlight_line(location)
        column_length = if location.begin.line == location.end.line
                          location.column_range.count
                        else
                          location.source_line.length - location.column
                        end

        ' ' * location.column + '^' * column_length
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-0.37.2 lib/rubocop/formatter/clang_style_formatter.rb
rubocop-0.37.1 lib/rubocop/formatter/clang_style_formatter.rb
rubocop-0.37.0 lib/rubocop/formatter/clang_style_formatter.rb
rubocop-0.36.0 lib/rubocop/formatter/clang_style_formatter.rb