Skip to content

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.

2 participants