diff --git a/lib/ruby_indexer/lib/ruby_indexer/configuration.rb b/lib/ruby_indexer/lib/ruby_indexer/configuration.rb index 9eff9327f4..8e03e0cb89 100644 --- a/lib/ruby_indexer/lib/ruby_indexer/configuration.rb +++ b/lib/ruby_indexer/lib/ruby_indexer/configuration.rb @@ -66,19 +66,18 @@ def indexables indexables = patterns.flat_map do |pattern| load_path_entry = T.let(nil, T.nilable(String)) - Dir.glob(pattern, File::FNM_PATHNAME | File::FNM_EXTGLOB) - .map! do |path| - path = File.expand_path(path) - # All entries for the same pattern match the same $LOAD_PATH entry. Since searching the $LOAD_PATH for every - # entry is expensive, we memoize it until we find a path that doesn't belong to that $LOAD_PATH. This - # happens on repositories that define multiple gems, like Rails. All frameworks are defined inside the - # Dir.pwd, but each one of them belongs to a different $LOAD_PATH entry - if load_path_entry.nil? || !path.start_with?(load_path_entry) - load_path_entry = $LOAD_PATH.find { |load_path| path.start_with?(load_path) } - end - - IndexablePath.new(load_path_entry, path) + Dir.glob(pattern, File::FNM_PATHNAME | File::FNM_EXTGLOB).map! do |path| + path = File.expand_path(path) + # All entries for the same pattern match the same $LOAD_PATH entry. Since searching the $LOAD_PATH for every + # entry is expensive, we memoize it until we find a path that doesn't belong to that $LOAD_PATH. This + # happens on repositories that define multiple gems, like Rails. All frameworks are defined inside the + # Dir.pwd, but each one of them belongs to a different $LOAD_PATH entry + if load_path_entry.nil? || !path.start_with?(load_path_entry) + load_path_entry = $LOAD_PATH.find { |load_path| path.start_with?(load_path) } end + + IndexablePath.new(load_path_entry, path) + end end # Remove user specified patterns