Add --regenerate-todo
command line option to rebuild .rubocop_todo.yml using its previous options
#8778
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added a new command line option
--regenerate-todo
which regenerates.rubocop_todo.yml
using the options used the last time (extracted from the comment at the top of the todo file), or act as--auto-gen-config
if there is no current valid todo file.At my work, we frequently re-run
rubocop --auto-gen-config
with various options in order to keep the todo file small and relevant. Each time, we have to copy the command from the previous version of the file in order to have it use the same options. Sometimes this is accidentally missed, which results in the todo file completely changing due to the changed options.With this change I'm trying to prevent that, by just having rubocop reuse its previous config generation options when requested by just running
rubocop --regenerate-todo
.I also made it so that it's possible to purposefully override the options with
--regenerate-todo
by passing them in as well. To facilitate this, I changed--no-offense-counts
,--auto-gen-only-exclude
, and--no-auto-gen-timestamp
to have both positive and negative variants, so this will work for example:Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).bundle exec rake default
. It executes all tests and RuboCop for itself, and generates the documentation.