Sha256: edae76dc50f82496eba9ff0d169727cfab1e9a0b13d7ee1a1c05e1f04114c07f

Contents?: true

Size: 1.01 KB

Versions: 235

Compression:

Stored size: 1.01 KB

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}"
          elsif offense.correctable?
            "[Correctable] #{offense.message}"
          else
            offense.message
          end
        message.tr("\n", ' ')
      end
    end
  end
end

Version data entries

235 entries across 226 versions & 21 rubygems

Version Path
harbr-0.2.4 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/formatter/emacs_style_formatter.rb
harbr-0.2.3 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/formatter/emacs_style_formatter.rb
harbr-0.2.2 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/formatter/emacs_style_formatter.rb
harbr-0.2.1 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/formatter/emacs_style_formatter.rb
harbr-0.2.0 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/formatter/emacs_style_formatter.rb
harbr-0.1.99 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/formatter/emacs_style_formatter.rb
harbr-0.1.98 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/formatter/emacs_style_formatter.rb
harbr-0.1.97 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/formatter/emacs_style_formatter.rb
harbr-0.1.96 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/formatter/emacs_style_formatter.rb
harbr-0.1.95 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/formatter/emacs_style_formatter.rb
harbr-0.1.94 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/formatter/emacs_style_formatter.rb
harbr-0.1.93 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/formatter/emacs_style_formatter.rb
harbr-0.1.91 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/formatter/emacs_style_formatter.rb
harbr-0.1.90 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/formatter/emacs_style_formatter.rb
harbr-0.1.89 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/formatter/emacs_style_formatter.rb
harbr-0.1.88 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/formatter/emacs_style_formatter.rb
harbr-0.1.87 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/formatter/emacs_style_formatter.rb
harbr-0.1.86 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/formatter/emacs_style_formatter.rb
harbr-0.1.85 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/formatter/emacs_style_formatter.rb
harbr-0.1.84 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/formatter/emacs_style_formatter.rb