-
-
Notifications
You must be signed in to change notification settings - Fork 285
Open
Description
blank?/present? on the relation loads the whole relation to determine if there are records in them. empty?/any? does a simple "exists" like query.
# bad
users.where(active: true).present?
users.where(active: true).blank?
users.where(active: true).any?
users.where(active: true).empty?One of these cases was responsible for 10% of the whole IO on a loaded production database. I also found 20+ other examples of this antipattern in the codebase.
Cop can be named something like Rails/WhereBlank.
Metadata
Metadata
Assignees
Labels
No labels