rubocop-performance
rubocop-performance copied to clipboard
Retire `Performance/Casecmp` cop
This follows up on the ideas generated in https://github.com/rubocop/rubocop-performance/issues/100.
It is confusing to have this cop enabled. Even when the autocorrection is marked as unsafe, the cop still directs people to use casecmp(...).zero?
, which is incorrect in non-ascii use cases.
This issue pairs with https://github.com/rubocop/rubocop/issues/9753, where I'm hoping we can create a Linting cop to suggest using casecmp?
.
There is another issue with the Performance/Casecmp
cop: For str1.downcase == str2.downcase
it suggests str1.casecmp(str2).zero?
. But then Style/NumericPredicate
jumps in to suggest str1.casecmp(str2) == 0
instead.
Another issue with this cop:
str.#{selector} == ('string')
str.#{selector} != ('string')
Both lines above return the same offence message.
Checkout lines: https://github.com/rubocop/rubocop-performance/blob/219bf570999d291ef657de97792b493e43f42393/spec/rubocop/cop/performance/casecmp_spec.rb#L19 https://github.com/rubocop/rubocop-performance/blob/219bf570999d291ef657de97792b493e43f42393/spec/rubocop/cop/performance/casecmp_spec.rb#L41