summaryrefslogtreecommitdiffstats
path: root/app/helpers
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2023-01-17 01:38:27 +0000
committerGo MAEDA <maeda@farend.jp>2023-01-17 01:38:27 +0000
commit0b6f4c6811a4a4e823674e3bb8b970ee46a9194b (patch)
tree341119beb1c247727c68ba9913a7a2bfc3fa3006 /app/helpers
parent97d07eb28573060085352e0e9046be16e29f5bfd (diff)
downloadredmine-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 'app/helpers')
-rw-r--r--app/helpers/application_helper.rb2
-rw-r--r--app/helpers/issue_relations_helper.rb2
-rw-r--r--app/helpers/members_helper.rb4
-rw-r--r--app/helpers/queries_helper.rb4
-rw-r--r--app/helpers/repositories_helper.rb4
5 files changed, 8 insertions, 8 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 72d9d8efd..43f32fbc7 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1503,7 +1503,7 @@ module ApplicationHelper
# Render the error messages for the given objects
def error_messages_for(*objects)
- objects = objects.map {|o| o.is_a?(String) ? instance_variable_get("@#{o}") : o}.compact
+ objects = objects.filter_map {|o| o.is_a?(String) ? instance_variable_get("@#{o}") : o}
errors = objects.map {|o| o.errors.full_messages}.flatten
render_error_messages(errors)
end
diff --git a/app/helpers/issue_relations_helper.rb b/app/helpers/issue_relations_helper.rb
index 02ff9d427..4323ea730 100644
--- a/app/helpers/issue_relations_helper.rb
+++ b/app/helpers/issue_relations_helper.rb
@@ -33,7 +33,7 @@ module IssueRelationsHelper
end
messages.map do |message, items|
- ids = items.map(&:issue_to_id).compact
+ ids = items.filter_map(&:issue_to_id)
if ids.empty?
message
else
diff --git a/app/helpers/members_helper.rb b/app/helpers/members_helper.rb
index e7e2e09e0..0e542768c 100644
--- a/app/helpers/members_helper.rb
+++ b/app/helpers/members_helper.rb
@@ -50,13 +50,13 @@ module MembersHelper
# Returns inheritance information for an inherited member role
def render_role_inheritance(member, role)
- content = member.role_inheritance(role).map do |h|
+ content = member.role_inheritance(role).filter_map do |h|
if h.is_a?(Project)
l(:label_inherited_from_parent_project)
elsif h.is_a?(Group)
l(:label_inherited_from_group, :name => h.name.to_s)
end
- end.compact.uniq
+ end.uniq
if content.present?
content_tag('em', content.join(", "), :class => "info")
diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb
index 86b647b83..d40ee2587 100644
--- a/app/helpers/queries_helper.rb
+++ b/app/helpers/queries_helper.rb
@@ -233,7 +233,7 @@ module QueriesHelper
value = column.value_object(item)
content =
if value.is_a?(Array)
- values = value.collect {|v| column_value(column, item, v)}.compact
+ values = value.filter_map {|v| column_value(column, item, v)}
safe_join(values, ', ')
else
column_value(column, item, value)
@@ -286,7 +286,7 @@ module QueriesHelper
def csv_content(column, item)
value = column.value_object(item)
if value.is_a?(Array)
- value.collect {|v| csv_value(column, item, v)}.compact.join(', ')
+ value.filter_map {|v| csv_value(column, item, v)}.join(', ')
else
csv_value(column, item, value)
end
diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb
index 2a338799e..719761265 100644
--- a/app/helpers/repositories_helper.rb
+++ b/app/helpers/repositories_helper.rb
@@ -52,7 +52,7 @@ module RepositoriesHelper
end
def render_changeset_changes
- changes = @changeset.filechanges.limit(1000).reorder('path').collect do |change|
+ changes = @changeset.filechanges.limit(1000).reorder('path').filter_map do |change|
case change.action
when 'A'
# Detects moved/copied files
@@ -66,7 +66,7 @@ module RepositoriesHelper
else
change
end
- end.compact
+ end
tree = {}
changes.each do |change|