Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --regenerate-todo command line option to rebuild .rubocop_todo.yml using its previous options #8778

Merged
merged 3 commits into from Sep 25, 2020

Conversation

dvandersluis
Copy link
Member

@dvandersluis dvandersluis commented Sep 23, 2020

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.

rubocop --auto-gen-config --no-auto-gen-timestamp --exclude-limit 1000

# ... later ...

rubocop --regenerate-todo
# uses exclude_limit: 1000, auto_gen_timestamp: false

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:

rubocop --regenerate-todo --auto-gen-timestamp
# uses exclude_limit: 1000, auto_gen_timestamp: true

Before submitting the PR make sure the following are checked:

  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Added an entry to the Changelog if the new code introduces user-observable changes. See changelog entry format.
  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Run bundle exec rake default. It executes all tests and RuboCop for itself, and generates the documentation.

…t they can be overridden when regenerating the todo file
…vious options, or acts as `--auto-gen-config` if there is no valid todo file.

Other options that affect `--auto-gen-config` are accepted, and can be passed in to override values in the previous todo.
eg. `--regenerate-todo --offense-counts` will supercede `--no-offense-counts`.
@bbatsov bbatsov merged commit ebe79a8 into rubocop:master Sep 25, 2020
@bbatsov
Copy link
Collaborator

bbatsov commented Sep 25, 2020

I love this change! Great work! 🙇‍♂️

@dvandersluis dvandersluis deleted the regenerate-todo branch January 18, 2021 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants