Class: RuboCop::Formatter::GitHubActionsFormatter

Inherits:
BaseFormatter
  • Object
show all
Defined in:
lib/rubocop/formatter/github_actions_formatter.rb

Overview

This formatter formats report data as GitHub Workflow commands resulting in GitHub check annotations when run within GitHub Actions.

Constant Summary collapse

ESCAPE_MAP =
{ '%' => '%25', "\n" => '%0A', "\r" => '%0D' }.freeze

Instance Attribute Summary

Attributes inherited from BaseFormatter

#options, #output

Instance Method Summary collapse

Methods inherited from BaseFormatter

#file_started, #initialize

Constructor Details

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

Instance Method Details

#file_finished(file, offenses) ⇒ Object



14
15
16
# File 'lib/rubocop/formatter/github_actions_formatter.rb', line 14

def file_finished(file, offenses)
  @offenses_for_files[file] = offenses unless offenses.empty?
end

#finished(_inspected_files) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/rubocop/formatter/github_actions_formatter.rb', line 18

def finished(_inspected_files)
  @offenses_for_files.each do |file, offenses|
    offenses.each do |offense|
      report_offense(file, offense)
    end
  end
  output.puts
end

#started(_target_files) ⇒ Object



10
11
12
# File 'lib/rubocop/formatter/github_actions_formatter.rb', line 10

def started(_target_files)
  @offenses_for_files = {}
end