123456789_123456789_123456789_123456789_123456789_

Class: RuboCop::Formatter::EmacsStyleFormatter

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: RuboCop::Formatter::BaseFormatter
Defined in: lib/rubocop/formatter/emacs_style_formatter.rb

Overview

This formatter displays the report data in format that’s easy to process in the Emacs text editor. The output is machine-parsable.

Class Method Summary

BaseFormatter - Inherited

Instance Attribute Summary

Instance Method Summary

BaseFormatter - Inherited

#file_finished

Invoked at the end of inspecting each files.

#file_started

Invoked at the beginning of inspecting each files.

#finished

Invoked after all files are inspected or interrupted by user.

#started

Invoked once before any files are inspected.

Constructor Details

This class inherits a constructor from RuboCop::Formatter::BaseFormatter

Instance Method Details

#file_finished(file, offenses)

[ GitHub ]

  
# File 'lib/rubocop/formatter/emacs_style_formatter.rb', line 9

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

#message(offense) (private)

[ GitHub ]

  
# File 'lib/rubocop/formatter/emacs_style_formatter.rb', line 24

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