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

NumericLiterals cop does auto-correction. #733

Merged
merged 1 commit into from Jan 13, 2014

Conversation

dblock
Copy link
Contributor

@dblock dblock commented Jan 12, 2014

No description provided.

def autocorrect(node)
@corrections << lambda do |corrector|
int = node.loc.expression.source.to_i
formatted_int = int.abs.to_s.reverse.gsub(/...(?=.)/,'\&_').reverse
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.01%) when pulling 9d26eab00049e5ad5a29bb50353aea6b8a50c2d9 on dblock:numeric-literals-autocorrect into 0490398 on bbatsov:master.

@coveralls
Copy link

Coverage Status

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
Copy link
Collaborator

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.

Copy link
Contributor Author

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..

@bbatsov
Copy link
Collaborator

bbatsov commented Jan 12, 2014

I guess some line is too long or something similar, cause the build is failing due to style problems.

@dblock
Copy link
Contributor Author

dblock commented Jan 13, 2014

All fixed up.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.01%) when pulling 07a86ca on dblock:numeric-literals-autocorrect into 0490398 on bbatsov:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.01%) when pulling 07a86ca on dblock:numeric-literals-autocorrect into 0490398 on bbatsov:master.

@dblock
Copy link
Contributor Author

dblock commented Jan 13, 2014

Note, rbx build error is unrelated.

@jonas054
Copy link
Collaborator

@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.

bbatsov added a commit that referenced this pull request Jan 13, 2014
NumericLiterals cop does auto-correction.
@bbatsov bbatsov merged commit 9043fa7 into rubocop:master Jan 13, 2014
@dblock dblock deleted the numeric-literals-autocorrect branch December 13, 2014 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants