Skip to content

RuboCop: Enable previously disabled cops

Problem

In Split up .rubocop_todo.yml into .rubocop_todo/*... (#354328 - closed) we've disabled some cops due to too many offenses to make the split easier.

Currently, there are 71 👮 rules disabled and we are adding offenses without notice.

Implementation Guide

Enable all 👮 rules which were previously disabled due to too many offenses to disallow any new offenses to sneak into the codebase.

  1. Pick a 👮 offense from The List below e.g. RSpec/ReturnFromStub
  2. Create a branch (e.g. 369268-rubocop-reneable-RSpec/ReturnFromStub)
    • Info: Using this issue ID (369268) in a branch name will add required labels and reference to this issue in the new merge request.
  3. Delete Enabled: false from the corresponding .rubocop_todo/ YAML file (e.g. https://gitlab.com/gitlab-org/gitlab/-/blob/211c7bdf7e171a6f7528d8b234343c591e44daaf/.rubocop_todo/rspec/return_from_stub.yml#L6)
  4. Re-generate the TODO list via e.g. bundle exec rake 'rubocop:todo:generate[RSpec/ReturnFromStub]'
  5. Commit changed YAML file and create an MR
  6. Mention this merge request in this issue
  7. 🎉

The list

A list containing all previously disabled 👮 rules due to too many offenses:

The script
# frozen_string_literal: true

require "yaml"

sha = `git rev-parse HEAD`.chomp

template = <<~MD
- [ ] [`%{rule_name}`](https://gitlab.com/gitlab-org/gitlab/-/blob/#{sha}/%{filename})
MD

Dir[".rubocop_todo/**/*.yml"].sort.each do |file|
  yaml = YAML.load_file(file) 

  rule_name, conf = yaml.first
  next unless conf["Enabled"] == false

  puts format(template, rule_name: rule_name, filename: file, sha: sha)
end
Edited by Peter Leitzen