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
Show warning message if passed string to 'Enabled' key in .rubocop.yml #7272
Show warning message if passed string to 'Enabled' key in .rubocop.yml #7272
Conversation
f38d9cb
to
6241927
Compare
hmm, How do I fix the |
5492f85
to
d7863b9
Compare
.rubocop_todo.yml
Outdated
@@ -17,7 +17,7 @@ Metrics/AbcSize: | |||
# Offense count: 47 | |||
# Configuration parameters: CountComments. | |||
Metrics/ClassLength: | |||
Max: 174 | |||
Max: 179 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't write this code for more short. So I changed max value in Metrics/ClassLength
in .rubocop_todo.yml
d7863b9
to
cd1403d
Compare
lib/rubocop/config_loader.rb
Outdated
|
||
warn Rainbow( | ||
"Cop `#{parent}` is enabled by value '#{value}' specified. " \ | ||
'It may unexpected behavior unless set true or false.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should probably raise an error instead and just say that property X of cop Y is supposed to be a boolean and it's not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. I change to raise an exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually instead of exception this can just be an error message with some error code. I guess the stack trace will just confuse most users.
It will also be a good idea to colour the names of the cop and the property in the error message and to mention its current value that's causing the error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's good.
cd1403d
to
99c15f4
Compare
You'll also have to rebase on top of the current |
99c15f4
to
7df13d0
Compare
I rebased this. 🙆♂️ |
7df13d0
to
529aaab
Compare
It causes unexpected cop warnings because treats as truthy value if passed neither true nor false in 'Enabled' key's value like "Enabled: disable". rubocop#7056
529aaab
to
b1e0911
Compare
@@ -5,6 +5,7 @@ | |||
### New features | |||
|
|||
* [#7274](https://github.com/rubocop-hq/rubocop/issues/7274): Add new `Lint/SendWithMixinArgument` cop. ([@koic][]) | |||
* [#7272](https://github.com/rubocop-hq/rubocop/pull/7272): Show warning message if passed string to `Enabled`, `Safe`, `SafeAutocorrect`, and `AutoCorrect` keys in .rubocop.yml. ([@unasuke][]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, This URL seems to be #7056.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shoud I have to change the url to #7056 ? (But already merged it... Sorry too late.)
Thanks! |
feature
It causes unexpected cop warnings because treats as truthy value if passed neither true nor false in 'Enabled' key's value like "Enabled: disable".
motivation
Our team occurred a problem that, unexpected cop was in effect.
The cause was the wrong config value like an "Enabled: disabled".
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.