From: Go MAEDA Date: Wed, 11 Sep 2019 08:08:38 +0000 (+0000) Subject: Code cleanup: RuboCop: Fix Performance/RedundantMatch and Rails/DynamicFindBy in... X-Git-Tag: 4.1.0~628 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e54f1b23ec996eb39bc57ed3930eec988770a2a2;p=redmine.git Code cleanup: RuboCop: Fix Performance/RedundantMatch and Rails/DynamicFindBy in app/controllers/auto_completes_controller.rb git-svn-id: http://svn.redmine.org/redmine/trunk@18451 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 6d965654d..a2d77a547 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -817,7 +817,6 @@ Performance/RedundantBlockCall: # Cop supports --auto-correct. Performance/RedundantMatch: Exclude: - - 'app/controllers/auto_completes_controller.rb' - 'app/models/issue_relation.rb' - 'lib/redmine/wiki_formatting/textile/formatter.rb' - 'lib/redmine/wiki_formatting/textile/redcloth3.rb' diff --git a/app/controllers/auto_completes_controller.rb b/app/controllers/auto_completes_controller.rb index e83374c9b..336885349 100644 --- a/app/controllers/auto_completes_controller.rb +++ b/app/controllers/auto_completes_controller.rb @@ -30,8 +30,8 @@ class AutoCompletesController < ApplicationController scope = scope.open(status == 'o') if status.present? scope = scope.where.not(:id => issue_id.to_i) if issue_id.present? if q.present? - if q.match(/\A#?(\d+)\z/) - issues << scope.find_by_id($1.to_i) + if q =~ /\A#?(\d+)\z/ + issues << scope.find_by(:id => $1.to_i) end issues += scope.like(q).order(:id => :desc).limit(10).to_a issues.compact!