From 9c76def19d914843373149a782f0d0a942e686b2 Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Thu, 5 Sep 2019 15:51:13 +0200 Subject: [PATCH] Maintenance: Applied rubocop Performance/Casecmp. --- .rubocop_todo.yml | 8 -------- app/models/channel/email_parser.rb | 2 +- app/models/channel/filter/database.rb | 2 +- lib/tasks/zammad/setup/db_config.rake | 2 +- 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 5902525df..633278d00 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -47,14 +47,6 @@ Metrics/ModuleLength: Metrics/PerceivedComplexity: Max: 115 -# Offense count: 3 -# Cop supports --auto-correct. -Performance/Casecmp: - Exclude: - - 'app/models/channel/email_parser.rb' - - 'app/models/channel/filter/database.rb' - - 'lib/tasks/zammad/setup/db_config.rake' - # Offense count: 3 # Cop supports --auto-correct. Rails/ApplicationRecord: diff --git a/app/models/channel/email_parser.rb b/app/models/channel/email_parser.rb index cc789e860..9852baf94 100644 --- a/app/models/channel/email_parser.rb +++ b/app/models/channel/email_parser.rb @@ -331,7 +331,7 @@ returns end return true if !class_name - if class_name.downcase == 'article' + if class_name.casecmp('article').zero? class_name = 'Ticket::Article' end return true if !attribute diff --git a/app/models/channel/filter/database.rb b/app/models/channel/filter/database.rb index 113b628de..4fa279e4b 100644 --- a/app/models/channel/filter/database.rb +++ b/app/models/channel/filter/database.rb @@ -48,7 +48,7 @@ module Channel::Filter::Database Rails.logger.info " perform '#{key.downcase}' = '#{meta.inspect}'" - if key.downcase == 'x-zammad-ticket-tags' && meta['value'].present? && meta['operator'].present? + if key.casecmp('x-zammad-ticket-tags').zero? && meta['value'].present? && meta['operator'].present? mail[ 'x-zammad-ticket-tags'.downcase.to_sym ] ||= [] tags = meta['value'].split(',') diff --git a/lib/tasks/zammad/setup/db_config.rake b/lib/tasks/zammad/setup/db_config.rake index 881c143bd..b24eea796 100644 --- a/lib/tasks/zammad/setup/db_config.rake +++ b/lib/tasks/zammad/setup/db_config.rake @@ -15,7 +15,7 @@ namespace :zammad do next if FileUtils.identical?(template, destination) printf 'config/database.yml: File exists. Overwrite? [y/N] ' - next if STDIN.gets.chomp.downcase != 'y' + next if !STDIN.gets.chomp.casecmp('y').zero? end FileUtils.cp(template, destination)