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

Update the doc for Performance/Count #378

Merged
merged 1 commit into from
Oct 23, 2023

Conversation

ryym
Copy link
Contributor

@ryym ryym commented Oct 22, 2023

This pull request improves the doc for Performance/Count .

  • Removed almost duplicate sentences (left the latter one only):

    ActiveRecord's count ignores the block that is passed to it.

    ActiveRecord will ignore the block that is passed to count.

  • Added Rails version that fixed the described count method issue. Since it has been fixed in 2016, newer Rails users will not encounter this issue.

    Fixed ActiveRecord::Relation#count to use Ruby's Enumerable#count for counting records when a block is passed as argument instead of silently ignoring the passed block. (Pull Request)


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.

@@ -544,8 +544,7 @@ passed to the `count` call.
=== Safety

This cop is unsafe because it has known compatibility issues with `ActiveRecord` and other
frameworks. ActiveRecord's `count` ignores the block that is passed to it.
`ActiveRecord` will ignore the block that is passed to `count`.
frameworks. Before Rails 5.1, `ActiveRecord` will ignore the block that is passed to `count`.
Copy link
Member

Choose a reason for hiding this comment

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

This adoc file is auto-generated, so no changes are necessary.

@koic
Copy link
Member

koic commented Oct 22, 2023

Can you squash your commits into one?

- Remove duplicate sentences
- Specify Rails version about ActiveRecord behavior description

The described behavior of `count` method has been fixed at Rails 5.1.

<https://guides.rubyonrails.org/5_1_release_notes.html>

> Fixed ActiveRecord::Relation#count to use Ruby's Enumerable#count for counting records when a block is passed as argument instead of silently ignoring the passed block.
@ryym ryym force-pushed the update_doc_for_performance_count branch from ba1885e to 9c6704e Compare October 22, 2023 08:50
@ryym
Copy link
Contributor Author

ryym commented Oct 22, 2023

Thank you for your reviewing!
I squashed the commits and discarded the change of adoc file.

@ryym ryym requested a review from koic October 22, 2023 08:56
@koic koic merged commit 18b63bc into rubocop:master Oct 23, 2023
10 checks passed
@ryym ryym deleted the update_doc_for_performance_count branch October 23, 2023 04:37
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