Improve spec coverage for RuboCop rules

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Problem

After enabling simplecov in "fast specs" and running specs for RuboCop rules with code coverage enabled we are seeing that some 👮 rules are (partly) missing specs:

SIMPLECOV=1 bin/rspec -f p $(find spec/rubocop -name "*_spec.rb")

The list

MR File % covered Lines
!97497 (merged) rubocop/cop/gitlab/avoid_feature_get.rb 0.00 % 27
!97493 (merged) rubocop/cop/gitlab/keys_first_and_values_first.rb 0.00 % 57
rubocop/cop/avoid_route_redirect_leading_slash.rb 80.95 % 52
rubocop/cop/gitlab/mark_used_feature_flags.rb 88.72 % 282
rubocop/cop/performance/ar_count_each.rb 90.00 % 45
rubocop/cop/performance/ar_exists_and_present_blank.rb 92.31 % 57
rubocop/cop/migration/update_column_in_batches.rb 95.45 % 45
rubocop/cop/gitlab/finder_with_find_by.rb 95.83 % 54
rubocop/cop/migration/add_concurrent_foreign_key.rb 95.83 % 53
!143663 (merged) rubocop/cop/migration/add_limit_to_text_columns.rb 97.18 % 168
rubocop/cop/gitlab/feature_available_usage.rb 98.04 % 99

Screenshot

Line coverage for rubocop/*
Screenshot_from_2022-03-09_14-39-34

Proposed solution

Bring test coverage to 100% for each for the 👮 rules above.

Implementation Guide

  1. Pick a 👮 rule from the table above ☝️ .
  2. Create a well-named branch 355012-rubocop-improve-spec-coverage-<Cop/Name>.
    • Hint: Prefixing a branch name with an issue IID (355012) will add required labels and references to this issue in the new merge request.
  3. Inspect resulting line coverage in your browser via file:///path-to-your-gdk/coverage/index.html#_Tooling
  4. Write specs for lines which aren't covered by a spec.
  5. Create a merge request and link the MR in the table above replacing <!-- Link MR --> with !<MR-IID>.
  6. 🎉
Edited by 🤖 GitLab Bot 🤖