Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change output timing of GitHubActionsFormatter #10730

Merged

Conversation

r7kamura
Copy link
Contributor

@r7kamura r7kamura commented Jun 20, 2022

This pull request changes the output timing of GitHubActionsFormatter from #file_finished to #finished.

When workflow commands are used, file path and line number are hidden in the GitHub Action log. So, if we want to use github formatter and still be able to identify the problematic file info from the log, we need to use it with another formatter like --format progress --format github.

However, the output timing of the current github formatter is a bit inconveninent when used with the progress formatter like this:

$ bundle exec rubocop --format progress --format github
Inspecting 2 files
C
Error: Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem `paper_trail` should appear before `foo`.
Error: Layout/TrailingEmptyLines: 1 trailing blank lines detected.
C
Error: Layout/LeadingCommentSpace: Missing space after `#`.
Error: Layout/TrailingEmptyLines: 1 trailing blank lines detected.
Offenses:
Gemfile:77:1: C: [Correctable] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem bar should appear before foo.
gem 'bar'
^^^^^^^^^
Gemfile:234:1: C: [Correctable] Layout/TrailingEmptyLines: 1 trailing blank lines detected.
config/application.rb:24:5: C: [Correctable] Layout/LeadingCommentSpace: Missing space after #.
    #FIXME: baz
    ^^^^^^^^^^^
config/application.rb:85:1: C: [Correctable] Layout/TrailingEmptyLines: 1 trailing blank lines detected.

After this pull request's change, the output will be:

$ docker-compose run --rm web bundle exec rubocop Gemfile config/application.rb  --format progress --format github
Starting builderpadjp_elasticsearch_1 ... done
Creating builderpadjp_web_run         ... done
Inspecting 2 files
CC

Offenses:

Gemfile:77:1: C: [Correctable] Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem bar should appear before foo.
gem 'bar'
^^^^^^^^^
Gemfile:234:1: C: [Correctable] Layout/TrailingEmptyLines: 1 trailing blank lines detected.
config/application.rb:24:5: C: [Correctable] Layout/LeadingCommentSpace: Missing space after #.
    #FIXME: baz
    ^^^^^^^^^^^
config/application.rb:85:1: C: [Correctable] Layout/TrailingEmptyLines: 1 trailing blank lines detected.

2 files inspected, 4 offenses detected, 4 offenses autocorrectable

::error file=Gemfile,line=77,col=1::Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem `bar` should appear before `foo`.
::error file=Gemfile,line=234,col=1::Layout/TrailingEmptyLines: 1 trailing blank lines detected.
::error file=config/application.rb,line=24,col=5::Layout/LeadingCommentSpace: Missing space after `#`.
::error file=config/application.rb,line=85,col=1::Layout/TrailingEmptyLines: 1 trailing blank lines detected.
ERROR: 1

Since github formatter is mainly for machine use, I think it won't matter if the output timing changes.


Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.

@bbatsov
Copy link
Collaborator

bbatsov commented Jun 21, 2022

I'm fine with the proposed changes.

@koic
Copy link
Member

koic commented Jun 21, 2022

@r7kamura Can you add a changelog entry?

@r7kamura r7kamura force-pushed the feature/improve-github-formatter-timing branch from d5a33c3 to fe800ad Compare June 21, 2022 21:25
@r7kamura
Copy link
Contributor Author

Thanks, I added changelog/change_change_output_timing_of.md👌

@koic koic merged commit 1dd8ee3 into rubocop:master Jun 21, 2022
@koic
Copy link
Member

koic commented Jun 21, 2022

Thanks!

@r7kamura r7kamura deleted the feature/improve-github-formatter-timing branch June 22, 2022 00:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants