Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # 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!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants