Fix Rubocop CodeReuse/ActiveRecord for find_each

Problem

The following code does not fire any offenses (correctly):

user.pipelines.cancelable.find_each do |pipeline|
  pipeline.cancel_running
end

However, the equivalent code does fire a CodeReuse/ActiveRecord offese on find_each:

user.pipelines.cancelable.find_each(&:cancel_running)

Proposal

I think the problem is in Rubocop::Cop::CodeReuse::ActiveRecord#on_send where we should check if the first_arg is a block

Edited Jul 07, 2025 by 🤖 GitLab Bot 🤖
Assignee Loading
Time tracking Loading