Create `Cop` that flags inefficient use of `count`, `present?`, etc.
As part of the workshop on performance optimization, it was pointed out that there are some common idioms in ActiveRecord around counting rows or testing for existence that are inefficient and can often be directly replaced with more efficient versions (example: using count
instead of size
).
They are documented in this article: https://www.speedshop.co/2019/01/10/three-activerecord-mistakes.html
It should be relatively straight forward to detect these with a Cop
. This might already be covered by rubocop-rails but it can't hurt to double check.