1
0
mirror of https://github.com/meineerde/redmine.git synced 2025-12-20 15:31:12 +00:00

code cleanup: rubocop: fix Performance/Casecmp in lib/redmine/codeset_util.rb

git-svn-id: http://svn.redmine.org/redmine/trunk@18503 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2019-09-21 15:54:25 +00:00
parent 8fb0ec3c3b
commit f66cc7db80
2 changed files with 2 additions and 3 deletions

View File

@ -727,7 +727,6 @@ Naming/VariableNumber:
# Cop supports --auto-correct. # Cop supports --auto-correct.
Performance/Casecmp: Performance/Casecmp:
Exclude: Exclude:
- 'lib/redmine/codeset_util.rb'
- 'lib/redmine/scm/adapters/bazaar_adapter.rb' - 'lib/redmine/scm/adapters/bazaar_adapter.rb'
Performance/FixedSize: Performance/FixedSize:

View File

@ -22,7 +22,7 @@ module Redmine
return str return str
end end
enc = encoding.blank? ? "UTF-8" : encoding enc = encoding.blank? ? "UTF-8" : encoding
if enc.upcase != "UTF-8" if enc.casecmp("UTF-8") != 0
str.force_encoding(enc) str.force_encoding(enc)
str = str.encode("UTF-8", :invalid => :replace, str = str.encode("UTF-8", :invalid => :replace,
:undef => :replace, :replace => '?') :undef => :replace, :replace => '?')
@ -62,7 +62,7 @@ module Redmine
str = str.dup str = str.dup
str ||= '' str ||= ''
str.force_encoding('UTF-8') str.force_encoding('UTF-8')
if encoding.upcase != 'UTF-8' if encoding.casecmp('UTF-8') != 0
str = str.encode(encoding, :invalid => :replace, str = str.encode(encoding, :invalid => :replace,
:undef => :replace, :replace => '?') :undef => :replace, :replace => '?')
else else