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

AutocorrectLogic#safe_autocorrect? may be returning true erroneously #11715

Closed
searls opened this issue Mar 18, 2023 · 4 comments · Fixed by #11729
Closed

AutocorrectLogic#safe_autocorrect? may be returning true erroneously #11715

searls opened this issue Mar 18, 2023 · 4 comments · Fixed by #11729
Labels

Comments

@searls
Copy link

searls commented Mar 18, 2023

It appears like safe_autocorrect? may be returning true for cases where autocorrection is not safe.

For example, Lint/BooleanSymbol supports autocorrection, but the docs report that it is unsafe. Additionally, the RuboCop's default.yml agrees and has SafeAutoCorrect: false.

However, if you were to instantiate the cop and ask if it was safe, it would return true:

RuboCop::Cop::Lint::BooleanSymbol.new.safe_autocorrect?
=> true

Is this a bug? It's affecting which cops Standard thinks are safe to autocorrect, so I'm trying to find the proper way to ascertain whether a violation is safely autocorrectable programmatically.

Thank you for all your hard work!!! 💚

@searls
Copy link
Author

searls commented Mar 19, 2023

@koic, could you take a look at this? I am concerned Standard may be running unsafe autocorrections as a result 😬

@koic
Copy link
Member

koic commented Mar 19, 2023

Yeah, I'll look into it later. Thank you for the feedback!

@koic koic added the bug label Mar 23, 2023
koic added a commit to koic/rubocop that referenced this issue Mar 23, 2023
Fixes rubocop#11715.

There was an issue where the default configuration was not loaded
when instantiating cop with no arguments. This patch ensures
default configuration by passing `RuboCop::ConfigLoader.default_configuration`
to `RuboCop::Config.new` default argument.
@koic
Copy link
Member

koic commented Mar 23, 2023

This looks like unexpected behavior. Either way I think it's a bug and opened #11729 as a patch.

bbatsov pushed a commit that referenced this issue Mar 23, 2023
Fixes #11715.

There was an issue where the default configuration was not loaded
when instantiating cop with no arguments. This patch ensures
default configuration by passing `RuboCop::ConfigLoader.default_configuration`
to `RuboCop::Config.new` default argument.
@searls
Copy link
Author

searls commented Mar 23, 2023

Thanks!!

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

Successfully merging a pull request may close this issue.

2 participants