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

Feature Suggestion: Detect redundant entries in .rubocop_todo.yml #8019

Open
andyw8 opened this issue May 24, 2020 · 3 comments
Open

Feature Suggestion: Detect redundant entries in .rubocop_todo.yml #8019

andyw8 opened this issue May 24, 2020 · 3 comments

Comments

@andyw8
Copy link
Contributor

andyw8 commented May 24, 2020

Is your feature request related to a problem? Please describe.

When adding RuboCop to an existing codebase, it's common to add an automatically generated .rubocop_todo.yml. Over time, this can become stale as code is changed. Entries in the config can end up referring to issues which no longer exist. The additional noise makes it harder to tell how many genuine issues are remaining.

Describe the solution you'd like

Add a flag to detect if the config includes redundant entries. If so, it should suggest that the user re-generates .rubocop_todo.yml.

The implementation would likely involve re-running RuboCop with --auto-gen-config option and comparing it to the existing one, ignoring any comments.

Describe alternatives you've considered

n/a

Additional context

n/a

@Mangara
Copy link
Contributor

Mangara commented Sep 16, 2020

This would be really useful!

An alternative implementation could be to run the cop as normal for excluded files, but to report an error if the cop passes (or if the file no longer exists). Glob patterns may need special handling as well.

@jonas054
Copy link
Collaborator

A problem I see is that sometimes we exclude files or disable cops because we're not interested in the results of that inspection. It's not always to hide existing offenses. This would be a problem if we want to implement checking of configuration in ./.rubocop.yml, or similar.

For .rubocop_todo.yml it's a bit more straight forward. The exclusions and disablings made there could always be checked to see if they are still relevant. On the other hand, is that really a significant improvement over re-running rubocop --auto-gen-config and checking the diff to see if you want to keep the changes in .rubocop_todo.yml?

@andyw8
Copy link
Contributor Author

andyw8 commented Jul 10, 2021

For .rubocop_todo.yml it's a bit more straight forward.

Yes, it would probably make sense for this to default to only checking .rubocop_todo.yml, perhaps with an option to override with another filename.

On the other hand, is that really a significant improvement over re-running rubocop --auto-gen-config

It's not game-changing, it's would just one less thing to have to remember to do manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants