Load missing rubocop-rails in database cop rule
What does this MR do and why?
Load missing rubocop-rails in database cop rule
The cop rule Database/AvoidUsingPluckWithoutLimit requires
rubocop-rails
to be loaded to prevent flaky specs resulting in errors
like: uninitialized constant RuboCop::Rails
References
- Contributes to [Test] spec/tasks/rubocop_rake_spec.rb | ruboco... (#526439)
How to set up and validate locally
-
bin/rspec ./spec/tasks/rubocop_rake_spec.rb spec/rubocop/cop/database/avoid_using_pluck_without_limit_spec.rb
✅
On master
we've seen:
Failures:
1) rubocop rake tasks todo:generate without arguments generates TODOs for all RuboCop rules
Got 2 failures:
1.1) Failure/Error:
expect { run_task }.to output(<<~OUTPUT).to_stdout
Generating RuboCop TODOs with:
rubocop --parallel --format RuboCop::Formatter::TodoFormatter
This might take a while...
Written to .rubocop_todo/layout/space_around_operators.yml
Written to .rubocop_todo/layout/trailing_empty_lines.yml
Written to .rubocop_todo/style/frozen_string_literal_comment.yml
OUTPUT
expected block to output "Generating RuboCop TODOs with:\n rubocop --parallel --format RuboCop::Formatter::TodoFormatter\n\nT...layout/trailing_empty_lines.yml\nWritten to .rubocop_todo/style/frozen_string_literal_comment.yml\n" to stdout, but output "Generating RuboCop TODOs with:\n rubocop --parallel --format RuboCop::Formatter::TodoFormatter\n\nThis might take a while...\n"
Diff:
@@ -2,7 +2,4 @@
rubocop --parallel --format RuboCop::Formatter::TodoFormatter
This might take a while...
-Written to .rubocop_todo/layout/space_around_operators.yml
-Written to .rubocop_todo/layout/trailing_empty_lines.yml
-Written to .rubocop_todo/style/frozen_string_literal_comment.yml
# ./spec/tasks/rubocop_rake_spec.rb:120:in `block (4 levels) in <top (required)>'
# ./spec/tasks/rubocop_rake_spec.rb:70:in `block (6 levels) in <top (required)>'
# ./spec/tasks/rubocop_rake_spec.rb:186:in `with_inflections'
# ./spec/tasks/rubocop_rake_spec.rb:69:in `block (5 levels) in <top (required)>'
# ./rubocop/formatter/todo_formatter.rb:66:in `with_base_directory'
# ./spec/tasks/rubocop_rake_spec.rb:68:in `block (4 levels) in <top (required)>'
# ./spec/tasks/rubocop_rake_spec.rb:67:in `chdir'
# ./spec/tasks/rubocop_rake_spec.rb:67:in `block (3 levels) in <top (required)>'
# ./spec/support/system_exit_detected.rb:7:in `block (2 levels) in <top (required)>'
1.2) Failure/Error:
expect(rubocop_todo_dir_listing).to contain_exactly(
'layout/space_around_operators.yml',
'layout/trailing_empty_lines.yml',
'style/frozen_string_literal_comment.yml'
)
expected collection contained: ["layout/space_around_operators.yml", "layout/trailing_empty_lines.yml", "style/frozen_string_literal_comment.yml"]
actual collection contained: []
the missing elements were: ["layout/space_around_operators.yml", "layout/trailing_empty_lines.yml", "style/frozen_string_literal_comment.yml"]
# ./spec/tasks/rubocop_rake_spec.rb:130:in `block (4 levels) in <top (required)>'
# ./spec/tasks/rubocop_rake_spec.rb:70:in `block (6 levels) in <top (required)>'
# ./spec/tasks/rubocop_rake_spec.rb:186:in `with_inflections'
# ./spec/tasks/rubocop_rake_spec.rb:69:in `block (5 levels) in <top (required)>'
# ./rubocop/formatter/todo_formatter.rb:66:in `with_base_directory'
# ./spec/tasks/rubocop_rake_spec.rb:68:in `block (4 levels) in <top (required)>'
# ./spec/tasks/rubocop_rake_spec.rb:67:in `chdir'
# ./spec/tasks/rubocop_rake_spec.rb:67:in `block (3 levels) in <top (required)>'
# ./spec/support/system_exit_detected.rb:7:in `block (2 levels) in <top (required)>'
Finished in 2.83 seconds (files took 2.22 seconds to load)
19 examples, 1 failure
Failed examples:
rspec ./spec/tasks/rubocop_rake_spec.rb:119 # rubocop rake tasks todo:generate without arguments generates TODOs for all RuboCop rules
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Edited by Peter Leitzen