
Description
Is your feature request related to a problem? Please describe.
Too often I see folks using pluck
as part of a query when they really should choose select
. Examples that come most readily to mind are part of where
clauses, especially when a subquery is involved. For example, I sometimes see something like
Widget.where(id: FooFactory.spectacular.pluck(:widget_id))
which will be very inefficient as the number of FooFactory
s increases, since the ever-larger pluck
ed Ruby array size will slow things down, making the following preferable (if a subquery is necessary at all):
Widget.where(id: FooFactory.spectacular.select(:widget_id))
Describe the solution you'd like
Introduce a Rubocop rule that will find, and possibly auto-correct, usages of pluck
(and/or other finder methods??) in a subquery.
Describe alternatives you've considered
It's obviously possible to socialize knowledge about this, and I have tried, but a Rubocop rule will enforce even for those whom such socialization doesn't reach.
Additional context
Please forgive if I'm asking about this in the wrong way or with too little detail. Whereas I'm a huge Rubocop fan and grateful user, this is my first time requesting a feature or considering contributing to Rubocop.