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

Add new Performance/Squeeze cop #124

Merged
merged 1 commit into from
Jun 8, 2020
Merged

Conversation

fatkodima
Copy link
Contributor

This cop will detect places where gsubing of multiple runs of single character by single character can be replaced by squeeze method.

# bad
str.gsub(/a+/, 'a')
str.gsub(/\\+/, '\\')
str.gsub!(/ +/, ' ')

# good
str.squeeze('a')
str.squeeze('\\')
str.squeeze!(' ')

Reference - https://github.com/JuanitoFatas/fast-ruby#remove-extra-spaces-or-other-contiguous-characters-code

@fatkodima
Copy link
Contributor Author

Updated.

@koic koic merged commit ee9d70c into rubocop:master Jun 8, 2020
@koic
Copy link
Member

koic commented Jun 8, 2020

Thanks!

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

2 participants