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

Supplied config file not used when .rubocop.yml exists when regenerating TODO #10657

Closed
jimryan opened this issue May 20, 2022 · 0 comments · Fixed by #10658
Closed

Supplied config file not used when .rubocop.yml exists when regenerating TODO #10657

jimryan opened this issue May 20, 2022 · 0 comments · Fixed by #10658

Comments

@jimryan
Copy link

jimryan commented May 20, 2022

I'm not sure if this is a known issue or not, but I didn't see anything in the docs about it.

We're working to add RuboCop to a mature codebase, and have developed a strategy that'll allow us to slowly introduce new cops. We essentially maintain two configs:

  • .rubocop.yml — Disables all cops by default, and just enables ones we've explicitly allowed after evaluating them, configuring as necessary, and fixing offenses.
  • .rubocop_wip.yml — The "typical" .rubocop.yml setup. Enables all default cops, and layers on our own configuration. Includes .rubocop_todo.yml.

The idea here is that we can run rubocop with .rubocop.yml and it'll run against cops we've evaluated/configured. That allows us to correct offenses for those cops on an ongoing basis.

For new code, after fixing those offenses, we'd like to run rubocop --config .rubocop_wip.yml --regenerate-todo to refresh the TODO file with all new offenses for cops we haven't evaluated yet (since the offenses for those which we have evaluated would have been fixed above).

However, that doesn't seem to work. It looks like rubocop ignores the --config flag and generates the .rubocop_todo.yml based off .rubocop.yml, so long as that file exists.

Demo with reproduction steps: https://github.com/jimryan/rubocop-custom-config-regenerate-todo-demo


Expected behavior

Supplied config file is used to generate the TODO.

Actual behavior

rubocop uses .rubocop.yml despite being explicitly passed a config file via --config

Steps to reproduce the problem

https://github.com/jimryan/rubocop-custom-config-regenerate-todo-demo

RuboCop version

$ [bundle exec] rubocop -V
1.29.1 (using Parser 3.1.2.0, rubocop-ast 1.18.0, running on ruby 2.7.6 arm64-darwin21)
nobuyo added a commit to nobuyo/rubocop that referenced this issue May 23, 2022
…ecified config file by option

Use `create_empty_file` instead of `create_file` with empty contents

Co-authored-by: Koichi ITO <koic.ito@gmail.com>

Update changelog/fix_autogenerateconfig_command_ignores_config.md

Co-authored-by: Koichi ITO <koic.ito@gmail.com>
koic added a commit that referenced this issue May 23, 2022
…fig-option

[Fix #10657] Fix `AutoGenerateConfig` command ignores specified config file by option
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 a pull request may close this issue.

1 participant