]> source.dussan.org Git - redmine.git/commitdiff
Fix RuboCop offense Style/MapCompactWithConditionalBlock (#39887).
authorGo MAEDA <maeda@farend.jp>
Thu, 11 Jul 2024 08:48:35 +0000 (08:48 +0000)
committerGo MAEDA <maeda@farend.jp>
Thu, 11 Jul 2024 08:48:35 +0000 (08:48 +0000)
git-svn-id: https://svn.redmine.org/redmine/trunk@22919 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/plugin.rb
lib/redmine/themes.rb
test/unit/lib/redmine/asset_path_test.rb

index 17a20f5a8bc6387e5ca2d37eec81b0854a029a4f..3e442cd128eb08b417282cbd13bd772871921756 100644 (file)
@@ -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)
index 191bafc21460c24bd1723d8259b58e11dc3074b5..80e846550c935307dc17cf2d6553d96d83bd1415 100644 (file)
@@ -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
index a88d0af5c2bc28b1a32f9f9783347eb1e4a6c719..a4f12f0e353699a9bce5525c4b813c7375ed28a2 100644 (file)
@@ -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 = {}