Sha256: 122da606b532b4a580fb7ee3febff012a5bbfc9046e788a5513d93a56d7cf50e

Contents?: true

Size: 955 Bytes

Versions: 57

Compression:

Stored size: 955 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Formatter
    # This formatter displays the report data in format that's
    # easy to process in the Emacs text editor.
    # The output is machine-parsable.
    class EmacsStyleFormatter < BaseFormatter
      def file_finished(file, offenses)
        offenses.each do |o|
          output.printf(
            "%<path>s:%<line>d:%<column>d: %<severity>s: %<message>s\n",
            path: file,
            line: o.line,
            column: o.real_column,
            severity: o.severity.code,
            message: message(o)
          )
        end
      end

      private

      def message(offense)
        message =
          if offense.corrected_with_todo?
            "[Todo] #{offense.message}"
          elsif offense.corrected?
            "[Corrected] #{offense.message}"
          else
            offense.message
          end
        message.tr("\n", ' ')
      end
    end
  end
end

Version data entries

57 entries across 52 versions & 6 rubygems

Version Path
plaid-14.13.0 vendor/bundle/ruby/3.0.0/gems/rubocop-0.91.1/lib/rubocop/formatter/emacs_style_formatter.rb
plaid-14.12.1 vendor/bundle/ruby/3.0.0/gems/rubocop-0.91.1/lib/rubocop/formatter/emacs_style_formatter.rb
plaid-14.12.0 vendor/bundle/ruby/2.6.0/gems/rubocop-0.91.1/lib/rubocop/formatter/emacs_style_formatter.rb
plaid-14.11.1 vendor/bundle/ruby/2.6.0/gems/rubocop-0.91.1/lib/rubocop/formatter/emacs_style_formatter.rb
plaid-14.10.0 vendor/bundle/ruby/2.6.0/gems/rubocop-0.91.1/lib/rubocop/formatter/emacs_style_formatter.rb
plaid-14.7.0 vendor/bundle/ruby/2.6.0/gems/rubocop-0.91.1/lib/rubocop/formatter/emacs_style_formatter.rb
rubocop-1.5.2 lib/rubocop/formatter/emacs_style_formatter.rb
rubocop-1.5.1 lib/rubocop/formatter/emacs_style_formatter.rb
rubocop-1.5.0 lib/rubocop/formatter/emacs_style_formatter.rb
rubocop-1.4.2 lib/rubocop/formatter/emacs_style_formatter.rb
rubocop-1.4.1 lib/rubocop/formatter/emacs_style_formatter.rb
rubocop-1.4.0 lib/rubocop/formatter/emacs_style_formatter.rb
rubocop-1.3.1 lib/rubocop/formatter/emacs_style_formatter.rb
rubocop-1.3.0 lib/rubocop/formatter/emacs_style_formatter.rb
rubocop-1.2.0 lib/rubocop/formatter/emacs_style_formatter.rb
rubocop-1.1.0 lib/rubocop/formatter/emacs_style_formatter.rb
rubocop-1.0.0 lib/rubocop/formatter/emacs_style_formatter.rb
rubocop-0.93.1 lib/rubocop/formatter/emacs_style_formatter.rb
rubocop-0.93.0 lib/rubocop/formatter/emacs_style_formatter.rb
rubocop-0.92.0 lib/rubocop/formatter/emacs_style_formatter.rb