From f66cc7db809436d16fe6518fab6ebfbe5fce1f9d Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Sat, 21 Sep 2019 15:54:25 +0000 Subject: [PATCH] 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 --- .rubocop_todo.yml | 1 - lib/redmine/codeset_util.rb | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 4c3334f2e..a0a5b04ef 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -727,7 +727,6 @@ Naming/VariableNumber: # Cop supports --auto-correct. Performance/Casecmp: Exclude: - - 'lib/redmine/codeset_util.rb' - 'lib/redmine/scm/adapters/bazaar_adapter.rb' Performance/FixedSize: diff --git a/lib/redmine/codeset_util.rb b/lib/redmine/codeset_util.rb index 657d057d6..53728928c 100644 --- a/lib/redmine/codeset_util.rb +++ b/lib/redmine/codeset_util.rb @@ -22,7 +22,7 @@ module Redmine return str end enc = encoding.blank? ? "UTF-8" : encoding - if enc.upcase != "UTF-8" + if enc.casecmp("UTF-8") != 0 str.force_encoding(enc) str = str.encode("UTF-8", :invalid => :replace, :undef => :replace, :replace => '?') @@ -62,7 +62,7 @@ module Redmine str = str.dup str ||= '' str.force_encoding('UTF-8') - if encoding.upcase != 'UTF-8' + if encoding.casecmp('UTF-8') != 0 str = str.encode(encoding, :invalid => :replace, :undef => :replace, :replace => '?') else