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

Report the count of files in the Worst and Offense Count formatters #11113

Merged

Conversation

hosamaly
Copy link
Contributor

@hosamaly hosamaly commented Oct 23, 2022

Report the count of files in the Worst and the Offence Counts formatters. Their output now looks like this:

# Worst:
4  exe/rubocop
3  spec/spec_helper.rb
2  lib/rubocop.rb
--
9  Total in 3 files

# Offenses:
2  CopC
1  CopA
1  CopB
--
4  Total in 1 files

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.

@hosamaly hosamaly force-pushed the report-file-counts-in-worst-formatter branch from 267e532 to 47c0362 Compare October 23, 2022 16:53
@hosamaly hosamaly changed the title Report the count of files in the Worst formatter Report the count of files in the Worst and Offense Count formatters Oct 23, 2022
output.puts '--'
output.puts "#{total_count} Total"
output.puts "#{total_count} Total offenses in #{file_count} offending files"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the word "offending" is redundant here, given the context.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had written it initially without "offending", but it felt a bit ambiguous: was this the total number of processed files, or the number of files with offenses?

I'm not worried too much, though, so I'm ok either way. What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here it should be quiet clear from the context, so probably less is more. Even the word "offenses" is kind of redundant IMO.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated it to show 3 Total in 2 files.

hosamaly and others added 3 commits October 25, 2022 17:35
…ormal usage

These specs called `file_finished` for one file only, even though the
test sets up multiple files. The method is now called for each file.
@hosamaly hosamaly force-pushed the report-file-counts-in-worst-formatter branch from f516429 to c0763f1 Compare October 25, 2022 17:38
@bbatsov bbatsov merged commit 1e4a684 into rubocop:master Oct 27, 2022
@bbatsov
Copy link
Collaborator

bbatsov commented Oct 27, 2022

Thanks!

@hosamaly hosamaly deleted the report-file-counts-in-worst-formatter branch October 27, 2022 12:11
koic added a commit that referenced this pull request Oct 28, 2022
Follow up #11113.

This commit fies the following build error.

```console
==> Failures

  1) RuboCop::CLI for a disabled cop reports no offense when enabled on part of a file
     Failure/Error:
             expect($stdout.string).to eq(<<~RESULT)

               --
               0  Total

             RESULT

       expected: "\n--\n0  Total\n\n"
            got: "\n--\n0  Total in 0 files\n\n"

       (compared using ==)

       Diff:
       @@ -1,4 +1,4 @@

        --
       -0  Total
       +0  Total in 0 files

     # ./spec/rubocop/cli_spec.rb:302:in `block (3 levels) in <top (required)>'
     # ./spec/support/cli_spec_behavior.rb:26:in `block (2 levels) in <top (required)>'
```
hosamaly added a commit to hosamaly/rubocop that referenced this pull request Nov 3, 2022
Update the sample output for the Offense Count and the Worst Offenders
formatters to match the changes in rubocop#11113.
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

2 participants