Created
December 3, 2019 21:18
-
-
Save clupprich/6a707ba3cef5c230a2dab1ea0897030a to your computer and use it in GitHub Desktop.
This file contains hidden or 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