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

performance/string_replacement broken autocorrect #2580

Closed
cthiel opened this issue Jan 5, 2016 · 3 comments
Closed

performance/string_replacement broken autocorrect #2580

cthiel opened this issue Jan 5, 2016 · 3 comments

Comments

@cthiel
Copy link

cthiel commented Jan 5, 2016

commit d4d6414 (or a change recently introduced in master) still seems to be producing wrong corrections. Also, the message displayed was a bit misleading.

I had code like:

  a = somestring.gsub(/\n/,'')

The cop mentioned:
C: Use delete instead of gsub.

auto-correct turned the code into:

  a = somestring.tr('\\n', '')

which is neither using delete, nor is is producing the expected (same) result.

@alexdowad
Copy link
Contributor

I have a fix. Pushing it to my open PR now.

@rrosenblum
Copy link
Contributor

Interesting issue. somestring.tr('\\n', '') and somestring.delete('\\n') would produce the same outcome and are nearly identical in efficiency. Thanks for the fix @alexdowad.

@alexdowad
Copy link
Contributor

😄

@bbatsov bbatsov closed this as completed in d246f66 Jan 7, 2016
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

No branches or pull requests

3 participants