-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[Fix #7023] Added auto-correction for Lint/NumberConversion
#7054
[Fix #7023] Added auto-correction for Lint/NumberConversion
#7054
Conversation
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.
Thank you for your contribution. I've left a few minor comments
@@ -108,4 +108,55 @@ | |||
RUBY | |||
end | |||
end | |||
|
|||
context 'autoccorrection' do |
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.
you can add expect_correction()
to the existing offending examples
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 indeed more elegant.
@@ -1463,6 +1463,7 @@ Lint/NumberConversion: | |||
Description: 'Checks unsafe usage of number conversion methods.' | |||
Enabled: false | |||
VersionAdded: '0.53' | |||
SafeAutoCorrect: 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.
You need to set the VersionChanged on the cop
lambda do |corrector| | ||
to_method(node) do |receiver, _to_method| | ||
corrector.replace(node.loc.expression, | ||
correct_method(node, receiver)) |
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.
you can just use node.receiver
and skip the to_method
matching, but I'm fine with your approach as well
config/default.yml
Outdated
@@ -1463,6 +1463,8 @@ Lint/NumberConversion: | |||
Description: 'Checks unsafe usage of number conversion methods.' | |||
Enabled: false | |||
VersionAdded: '0.53' | |||
VersionChanged: '0.69' |
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 would be 0.70
the actual release
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.
My bad.
Thanks! |
Fix #7023, Added auto-correction for
Lint/NumberConversion
Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).and description in grammatically correct, complete sentences.
bundle exec rake default
. It executes all tests and RuboCop for itself, and generates the documentation.