diff options
author | Go MAEDA <maeda@farend.jp> | 2023-01-17 01:38:27 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2023-01-17 01:38:27 +0000 |
commit | 0b6f4c6811a4a4e823674e3bb8b970ee46a9194b (patch) | |
tree | 341119beb1c247727c68ba9913a7a2bfc3fa3006 /lib | |
parent | 97d07eb28573060085352e0e9046be16e29f5bfd (diff) | |
download | redmine-0b6f4c6811a4a4e823674e3bb8b970ee46a9194b.tar.gz redmine-0b6f4c6811a4a4e823674e3bb8b970ee46a9194b.zip |
Ruby 2.7: Fix RuboCop offense Performance/MapCompact (#38134).
git-svn-id: https://svn.redmine.org/redmine/trunk@22055 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r-- | lib/redmine/field_format.rb | 4 | ||||
-rw-r--r-- | lib/redmine/helpers/gantt.rb | 2 | ||||
-rw-r--r-- | lib/redmine/helpers/time_report.rb | 2 | ||||
-rw-r--r-- | lib/redmine/my_page.rb | 4 | ||||
-rw-r--r-- | lib/redmine/scm/adapters/abstract_adapter.rb | 2 | ||||
-rw-r--r-- | lib/redmine/search.rb | 4 |
6 files changed, 9 insertions, 9 deletions
diff --git a/lib/redmine/field_format.rb b/lib/redmine/field_format.rb index 55800dd6b..e74dc20d7 100644 --- a/lib/redmine/field_format.rb +++ b/lib/redmine/field_format.rb @@ -868,7 +868,7 @@ module Redmine def possible_values_records(custom_field, object=nil) if object.is_a?(Array) - projects = object.map {|o| o.respond_to?(:project) ? o.project : nil}.compact.uniq + projects = object.filter_map {|o| o.respond_to?(:project) ? o.project : nil}.uniq projects.map {|project| possible_values_records(custom_field, project)}.reduce(:&) || [] elsif object.respond_to?(:project) && object.project scope = object.project.users @@ -934,7 +934,7 @@ module Redmine def possible_values_records(custom_field, object=nil, all_statuses=false) if object.is_a?(Array) - projects = object.map {|o| o.respond_to?(:project) ? o.project : nil}.compact.uniq + projects = object.filter_map {|o| o.respond_to?(:project) ? o.project : nil}.uniq projects.map {|project| possible_values_records(custom_field, project)}.reduce(:&) || [] elsif object.respond_to?(:project) && object.project scope = object.project.shared_versions diff --git a/lib/redmine/helpers/gantt.rb b/lib/redmine/helpers/gantt.rb index 448d3190e..3614829db 100644 --- a/lib/redmine/helpers/gantt.rb +++ b/lib/redmine/helpers/gantt.rb @@ -198,7 +198,7 @@ module Redmine # Returns the distinct versions of the issues that belong to +project+ def project_versions(project) - project_issues(project).collect(&:fixed_version).compact.uniq + project_issues(project).filter_map(&:fixed_version).uniq end # Returns the issues that belong to +project+ and are assigned to +version+ diff --git a/lib/redmine/helpers/time_report.rb b/lib/redmine/helpers/time_report.rb index 79ac6b020..c6e98ebf1 100644 --- a/lib/redmine/helpers/time_report.rb +++ b/lib/redmine/helpers/time_report.rb @@ -49,7 +49,7 @@ module Redmine @scope.includes(:activity). reorder(nil). group(@criteria.collect{|criteria| @available_criteria[criteria][:sql]} + time_columns). - joins(@criteria.collect{|criteria| @available_criteria[criteria][:joins]}.compact). + joins(@criteria.filter_map{|criteria| @available_criteria[criteria][:joins]}). sum(:hours).each do |hash, hours| h = {'hours' => hours} (@criteria + time_columns).each_with_index do |name, i| diff --git a/lib/redmine/my_page.rb b/lib/redmine/my_page.rb index 23885fea1..95af87a4c 100644 --- a/lib/redmine/my_page.rb +++ b/lib/redmine/my_page.rb @@ -48,11 +48,11 @@ module Redmine def self.block_options(blocks_in_use=[]) options = [] blocks.each do |block, block_options| - indexes = blocks_in_use.map do |n| + indexes = blocks_in_use.filter_map do |n| if n =~ /\A#{block}(__(\d+))?\z/ $2.to_i end - end.compact + end occurs = indexes.size block_id = indexes.any? ? "#{block}__#{indexes.max + 1}" : block diff --git a/lib/redmine/scm/adapters/abstract_adapter.rb b/lib/redmine/scm/adapters/abstract_adapter.rb index 7d211ad4f..ebd00d55f 100644 --- a/lib/redmine/scm/adapters/abstract_adapter.rb +++ b/lib/redmine/scm/adapters/abstract_adapter.rb @@ -329,7 +329,7 @@ module Redmine end def revisions - revisions ||= Revisions.new(collect{|entry| entry.lastrev}.compact) + revisions ||= Revisions.new(filter_map{|entry| entry.lastrev}) end end diff --git a/lib/redmine/search.rb b/lib/redmine/search.rb index 16c264ec5..83afe2c65 100644 --- a/lib/redmine/search.rb +++ b/lib/redmine/search.rb @@ -82,9 +82,9 @@ module Redmine klass = scope.singularize.camelcase.constantize results_by_scope[scope] += klass.search_results_from_ids(scope_and_ids.map(&:last)) end - result_ids_to_load.map do |scope, id| + result_ids_to_load.filter_map do |scope, id| results_by_scope[scope].detect {|record| record.id == id} - end.compact + end end # Returns the results ids, sorted by rank |