This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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