Draft: Add Rubocop: prefer `size` to `count`
What does this MR do and why?
- We already have a similar check that is only for HAML files where
each
is called: !28883 (merged) - It should always be safe to use
size
instead ofcount
becausesize
callscount
if the records are not already loaded. - https://github.com/rails/rails/blob/94b5cd3a20edadd6f6b8cf0bdf1a4d4919df86cb/activerecord/lib/active_record/relation.rb#L210
- https://www.speedshop.co/2019/01/10/three-activerecord-mistakes.html
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.