From 32b5992c22415ab667d78e0ef88089b0e0bf456e Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Thu, 11 Jul 2024 08:48:35 +0000 Subject: [PATCH] Fix RuboCop offense Style/MapCompactWithConditionalBlock (#39887). git-svn-id: https://svn.redmine.org/redmine/trunk@22919 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- lib/redmine/plugin.rb | 10 +++++----- lib/redmine/themes.rb | 8 ++++---- test/unit/lib/redmine/asset_path_test.rb | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/redmine/plugin.rb b/lib/redmine/plugin.rb index 17a20f5a8..3e442cd12 100644 --- a/lib/redmine/plugin.rb +++ b/lib/redmine/plugin.rb @@ -191,11 +191,11 @@ module Redmine end def asset_paths - if path.has_assets_dir? - base_dir = Pathname.new(path.assets_dir) - paths = base_dir.children.filter_map{|child| child if child.directory? } - Redmine::AssetPath.new(base_dir, paths, asset_prefix) - end + return unless path.has_assets_dir? + + base_dir = Pathname.new(path.assets_dir) + paths = base_dir.children.select(&:directory?) + Redmine::AssetPath.new(base_dir, paths, asset_prefix) end def <=>(plugin) diff --git a/lib/redmine/themes.rb b/lib/redmine/themes.rb index 191bafc21..80e846550 100644 --- a/lib/redmine/themes.rb +++ b/lib/redmine/themes.rb @@ -112,10 +112,10 @@ module Redmine def asset_paths base_dir = Pathname.new(path) - paths = base_dir.children.filter_map do |child| - child if child.directory? && - child.basename.to_s != "src" && - !child.basename.to_s.start_with?('.') + paths = base_dir.children.select do |child| + child.directory? && + child.basename.to_s != 'src' && + !child.basename.to_s.start_with?('.') end Redmine::AssetPath.new(base_dir, paths, asset_prefix) end diff --git a/test/unit/lib/redmine/asset_path_test.rb b/test/unit/lib/redmine/asset_path_test.rb index a88d0af5c..a4f12f0e3 100644 --- a/test/unit/lib/redmine/asset_path_test.rb +++ b/test/unit/lib/redmine/asset_path_test.rb @@ -22,7 +22,7 @@ require_relative '../../../test_helper' class Redmine::AssetPathTest < ActiveSupport::TestCase def setup assets_dir = Rails.root.join('test/fixtures/asset_path/foo') - paths = assets_dir.children.filter_map{|child| child if child.directory? && !child.basename.to_s.starts_with?(".")} + paths = assets_dir.children.select { |child| child.directory? && !child.basename.to_s.starts_with?('.') } @asset_path = Redmine::AssetPath.new(assets_dir, paths, 'plugin_assets/foo/') @assets = {} @transition_map = {} -- 2.39.5