• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nshkrdotcom / ElixirScope / f6aca62b40bb7398234ae7c2ebcd30112dae0f97

30 May 2025 02:04AM UTC coverage: 57.458% (-0.002%) from 57.46%
f6aca62b40bb7398234ae7c2ebcd30112dae0f97

push

github

NSHkr
refactor project_populator

185 of 249 new or added lines in 11 files covered. (74.3%)

3 existing lines in 2 files now uncovered.

6194 of 10780 relevant lines covered (57.46%)

3134.25 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.71
/lib/elixir_scope/ast_repository/enhanced/project_populator/file_discovery.ex
1
defmodule ElixirScope.ASTRepository.Enhanced.ProjectPopulator.FileDiscovery do
2
  @moduledoc """
3
  Handles discovery of Elixir files in a project directory.
4

5
  Provides functionality to:
6
  - Discover files based on include/exclude patterns
7
  - Filter files by size limits
8
  - Handle directory validation
9
  """
10

11
  require Logger
12

13
  @doc """
14
  Discovers all Elixir files in a project directory.
15
  """
16
  def discover_elixir_files(project_path, opts \\ []) do
17
    include_patterns = Keyword.get(opts, :include_patterns, ["**/*.ex", "**/*.exs"])
16✔
18
    exclude_patterns = Keyword.get(opts, :exclude_patterns, [])
16✔
19
    max_file_size = Keyword.get(opts, :max_file_size, 1_000_000)
16✔
20

21
    # Check if directory exists
22
    if not (File.exists?(project_path) and File.dir?(project_path)) do
16✔
23
      {:error, :directory_not_found}
24
    else
25
      try do
14✔
26
        files = include_patterns
14✔
27
        |> Enum.flat_map(fn pattern ->
28
          Path.wildcard(Path.join(project_path, pattern))
27✔
29
        end)
30
        |> Enum.uniq()
31
        |> Enum.reject(fn file ->
32
          Enum.any?(exclude_patterns, fn pattern ->
226✔
33
            String.contains?(file, pattern)
874✔
34
          end)
35
        end)
36
        |> Enum.filter(fn file ->
37
          case File.stat(file) do
226✔
38
            {:ok, %{size: size}} when size <= max_file_size -> true
226✔
NEW
39
            _ -> false
×
40
          end
41
        end)
42
        |> Enum.sort()
43

44
        Logger.debug("Discovered #{length(files)} Elixir files")
14✔
45
        {:ok, files}
46
      rescue
NEW
47
        e ->
×
48
          {:error, {:file_discovery_failed, Exception.message(e)}}
49
      end
50
    end
51
  end
52
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc