RuboCop: Load activesupport so core extensions are available
What does this MR do and why?
This MR ensures that ActiveSupport is always loaded in RuboCop to ensure that core extensions (like Enumerable#exclude?
) are available to Performance/CollectionLiteralInLoop
.
See gitlab-org/quality/engineering-productivity/master-broken-incidents#4013 (comment 1631785870) for further analysis.
How to set up and validate locally
# On this branch
# Merge commit of https://gitlab.com/gitlab-org/gitlab/-/merge_requests/133566 where RuboCop should have failed.
git checkout e32c2b44 -- spec/db/docs_spec.rb
bundle exec rubocop -C false spec/db/docs_spec.rb
Inspecting 1 file
C
Offenses:
spec/db/docs_spec.rb:173:80: C: Performance/CollectionLiteralInLoop: Avoid immutable Array literals in loops. It is better to extract it into a local variable or a constant.
database_base_models = Gitlab::Database.database_base_models.select { |k, _| %w[geo jh].exclude?(k) }
^^^^^^^^^^
spec/db/docs_spec.rb:182:80: C: Performance/CollectionLiteralInLoop: Avoid immutable Array literals in loops. It is better to extract it into a local variable or a constant.
database_base_models = Gitlab::Database.database_base_models.select { |k, _| %w[geo jh].exclude?(k) }
^^^^^^^^^^
1 file inspected, 2 offenses detected
# On master
# Changes from spec/db/docs_spec.rb are retained
git checkout master
bundle exec rubocop -C false spec/db/docs_spec.rb
Inspecting 1 file
.
1 file inspected, no offenses detected
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Peter Leitzen