Closed
Description
a.casecmp(b).zero?
is not an universal replacement for a.downcase == b.downcase
casecmp
only supports characters A-Za-z. downcase
supports special characters as well "ÄÖÜ".downcase == "äöü"
Expected behavior
Rubocop does not change the semantics of my program.
Actual behavior
Rubocop breaks my code.
Steps to reproduce the problem
foo.rb
# frozen_string_literal: true
if 'Grün'.downcase == 'GRÜN'.downcase
puts 'this should be the same'
else
puts 'rubocop broke my code'
end
rubocop -a foo.rb
foo.rb
# frozen_string_literal: true
if 'Grün'.casecmp('GRÜN').zero?
puts 'this should be the same'
else
puts 'rubocop broke my code'
end
RuboCop version
> bundle exec rubocop -V
0.80.0 (using Parser 2.7.0.3, running on ruby 2.5.3 x86_64-linux)
Metadata
Metadata
Assignees
Labels
No labels