Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@clupprich
Created December 3, 2019 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clupprich/6a707ba3cef5c230a2dab1ea0897030a to your computer and use it in GitHub Desktop.
Save clupprich/6a707ba3cef5c230a2dab1ea0897030a to your computer and use it in GitHub Desktop.
# Use it like so:
# > bundle exec {rubocop, standardrb} --require ./lib/github_actions_formatter.rb --format GithubActionsFormatter
class GithubActionsFormatter < RuboCop::Formatter::BaseFormatter
def file_finished(file, offenses)
return unless (uncorrected_offenses = offenses.reject(&:corrected?)).any?
uncorrected_offenses.each do |o|
output.printf("::error file=%s,line=%d,col=%d::%s\n", path_to(file), o.line, o.real_column, o.message.tr("\n", " "))
end
end
private
def path_to(file)
Pathname.new(file).relative_path_from(Pathname.new(Dir.pwd))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment