KEMBAR78
Fix `Performance/Count` cop error on empty selector block by viralpraxis · Pull Request #498 · rubocop/rubocop-performance · GitHub
Skip to content

Conversation

@viralpraxis
Copy link
Contributor

Something like

collection.reject { }.size

would lead to an error


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.

@viralpraxis viralpraxis force-pushed the fix-performance-count-cop-error-on-empty-selector-block branch from 366bbfc to 3cb75c8 Compare May 4, 2025 17:54
@viralpraxis viralpraxis requested a review from koic May 4, 2025 17:54
@viralpraxis viralpraxis force-pushed the fix-performance-count-cop-error-on-empty-selector-block branch from 3cb75c8 to 8a287ec Compare May 4, 2025 17:55
@viralpraxis viralpraxis force-pushed the fix-performance-count-cop-error-on-empty-selector-block branch from 8a287ec to c21a6e6 Compare May 4, 2025 18:10
Something like

```ruby
collection.reject { }.size
```

would lead to an error
@viralpraxis viralpraxis force-pushed the fix-performance-count-cop-error-on-empty-selector-block branch from c21a6e6 to 7b5aa7b Compare May 4, 2025 20:48
@viralpraxis viralpraxis requested a review from koic May 8, 2025 10:43
@koic koic merged commit 97af229 into rubocop:master May 10, 2025
15 checks passed
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.

2 participants