diff options
author | Go MAEDA <maeda@farend.jp> | 2019-09-11 08:08:38 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2019-09-11 08:08:38 +0000 |
commit | e54f1b23ec996eb39bc57ed3930eec988770a2a2 (patch) | |
tree | fa02b3c6872548af5259c37b31ac19eeb92e6ce9 | |
parent | a679b8a5caa3fb0871ea8a10b89d1d44f21e0ea3 (diff) | |
download | redmine-e54f1b23ec996eb39bc57ed3930eec988770a2a2.tar.gz redmine-e54f1b23ec996eb39bc57ed3930eec988770a2a2.zip |
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
-rw-r--r-- | .rubocop_todo.yml | 1 | ||||
-rw-r--r-- | app/controllers/auto_completes_controller.rb | 4 |
2 files changed, 2 insertions, 3 deletions
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! |