From 5403aee89945a803c79a672c23dc92c253c49ca3 Mon Sep 17 00:00:00 2001 From: Sijawusz Pur Rahnama Date: Wed, 17 Apr 2024 12:07:44 +0200 Subject: [PATCH] Make sure we only return files from `GlobUtils#expand` method --- src/ameba/glob_utils.cr | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/ameba/glob_utils.cr b/src/ameba/glob_utils.cr index 71cd0cb5..2ff2a119 100644 --- a/src/ameba/glob_utils.cr +++ b/src/ameba/glob_utils.cr @@ -20,10 +20,13 @@ module Ameba # expand(["spec/*.cr", "src"]) # => all files in src folder + first level specs # ``` def expand(globs) - globs.flat_map do |glob| - glob += "/**/*.cr" if File.directory?(glob) - Dir[glob] - end.uniq! + globs + .flat_map do |glob| + glob += "/**/*.cr" if File.directory?(glob) + Dir[glob] + end + .uniq! + .select! { |path| File.file?(path) } end private def rejected_globs(globs)