Skip to content

Generate RuboCop TODO config even without any offenses

Peter Leitzen requested to merge pl-rubocop-todo-formatter-no-exclude into master

What does this MR do and why?

Sometimes we enable new cop rules without any offenses and put this rule in "grace period". This is done in the TODO config in .rubocop_todo/**/*.yml because it's a temporary configuration which should be removed short after.

However, when regenerating TODOs for cops without any offenses we discarded to generate them.

This commit fixes this issue and generates a cop TODO config if:

  • Cop was previously disabled due to too many offenses
  • Cop is in grace period
  • Cop excludes files

Closes #377696 (closed).

Refs !100834 (comment 1133128572).

How to set up and validate locally

  1. Put a 👮 rule without any offenses (and thus no excluded files) in "grace period"

Add the following YAML to .rubocop_todo/style/unpack_first.yml:

---
Style/UnpackFirst:
  Details: grace period
  1. Regenerate TODOs via
bundle exec rake rubocop:todo:generate[Style/UnpackFirst]
Generating RuboCop TODOs with:
  rubocop --parallel --format RuboCop::Formatter::TodoFormatter --only Style/UnpackFirst

This might take a while...
Written to .rubocop_todo/style/unpack_first.yml
  1. Verify that .rubocop_todo/style/unpack_first.yml is still present

  2. Try the same on master and see that the config was removed 💥

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Peter Leitzen

Merge request reports