-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
NumericLiterals cop does auto-correction. #733
Conversation
def autocorrect(node) | ||
@corrections << lambda do |corrector| | ||
int = node.loc.expression.source.to_i | ||
formatted_int = int.abs.to_s.reverse.gsub(/...(?=.)/,'\&_').reverse |
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.
Coverage increased (+0.01%) when pulling 9d26eab00049e5ad5a29bb50353aea6b8a50c2d9 on dblock:numeric-literals-autocorrect into 0490398 on bbatsov:master. |
Coverage increased (+0.01%) when pulling 9d26eab00049e5ad5a29bb50353aea6b8a50c2d9 on dblock:numeric-literals-autocorrect into 0490398 on bbatsov:master. |
@corrections << lambda do |corrector| | ||
int = node.loc.expression.source.to_i | ||
formatted_int = int.abs.to_s.reverse.gsub(/...(?=.)/,'\&_').reverse | ||
formatted_int.insert 0, '-' if int < 0 |
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'd add the braces here as we tend to omit them only for DSL methods.
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 mean formatted_int.insert(0, '-') if int < 0
? Done..
I guess some line is too long or something similar, cause the build is failing due to style problems. |
All fixed up. |
Note, rbx build error is unrelated. |
@dblock I restarted the rbx job on Travis, and this time it passed (even though there was still some problem with rubygems). And for me it still displays the log from the failing run, but I watched it pass when I re-ran it. Strange. |
NumericLiterals cop does auto-correction.
No description provided.