-
-
Notifications
You must be signed in to change notification settings - Fork 279
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
The cop is detecting calls to all
on any object, not just ActiveRecord models. Using RSpec and Capybara, it can be useful to write code like:
page.all("button").select(&custom_filter).first.click
This is detected by the cop even though all
and first
do not refer to ActiveRecord methods.
Expected behavior
The cop should only complain about ActiveRecord's all
method.
Actual behavior
spec/system/consumer/shopping/shopping_spec.rb:564:20: C: [Correctable] Rails/RedundantActiveRecordAllMethod: Redundant all detected.
page.all("button", text: increase_quantity_symbol).last.click
^^^
Steps to reproduce the problem
echo '
describe "failing cop", type: :system do
it "detects Capybara calls" do
page.all("button").first
end
end
' > example_spec.rb
rubocop example_spec.rb
RuboCop version
Include the output of rubocop -V
or bundle exec rubocop -V
if using Bundler. Here's an example:
You can see extension cop versions (e.g. rubocop-rails, rubocop-performance, and others) output by rubocop -V,
include them as well. Here's an example:
$ [bundle exec] rubocop -V
1.56.2 (using Parser 3.2.2.3, rubocop-ast 1.29.0, running on ruby 3.1.4) [x86_64-linux]
- rubocop-rails 2.21.0
r-plus and jdudley1123
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working