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
rubocop-1.68.0 lib/rubocop/formatter/emacs_style_formatter.rb
rubocop-1.67.0 lib/rubocop/formatter/emacs_style_formatter.rb
rubocop-1.66.1 lib/rubocop/formatter/emacs_style_formatter.rb
rubocop-1.66.0 lib/rubocop/formatter/emacs_style_formatter.rb
rubocop-1.65.1 lib/rubocop/formatter/emacs_style_formatter.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/rubocop-1.64.1/lib/rubocop/formatter/emacs_style_formatter.rb
rubocop-1.65.0 lib/rubocop/formatter/emacs_style_formatter.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/rubocop-1.35.1/lib/rubocop/formatter/emacs_style_formatter.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/rubocop-1.35.1/lib/rubocop/formatter/emacs_style_formatter.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/rubocop-1.35.1/lib/rubocop/formatter/emacs_style_formatter.rb
katalyst-govuk-formbuilder-1.9.2 vendor/bundle/ruby/3.3.0/gems/rubocop-1.64.1/lib/rubocop/formatter/emacs_style_formatter.rb
rubocop-1.64.1 lib/rubocop/formatter/emacs_style_formatter.rb
rubocop-1.63.4 lib/rubocop/formatter/emacs_style_formatter.rb
rubocop-1.63.3 lib/rubocop/formatter/emacs_style_formatter.rb
rubocop-1.63.2 lib/rubocop/formatter/emacs_style_formatter.rb
harbr-2.8.1 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/formatter/emacs_style_formatter.rb
rubocop-1.63.1 lib/rubocop/formatter/emacs_style_formatter.rb
rubocop-1.63.0 lib/rubocop/formatter/emacs_style_formatter.rb
bison-0.1.0 vendor/bundle/ruby/3.2.0/gems/rubocop-1.62.1/lib/rubocop/formatter/emacs_style_formatter.rb
rubocop-1.62.1 lib/rubocop/formatter/emacs_style_formatter.rb