Skip to content

Commit

Permalink
Cobertura, catch all if module tye is unknown
Browse files Browse the repository at this point in the history
  • Loading branch information
gorghoa committed Mar 21, 2023
1 parent a001090 commit 9c04ab2
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/excoveralls/cobertura.ex
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,15 @@ defmodule ExCoveralls.Cobertura do
end

defp module_name(source) do
case Regex.run(~r/^def(?:module|protocol|impl)\s+(.*)\s+do$/m, source, capture: :all_but_first) do
cond do
# Is it an elixir module?
[module] = Regex.run(~r/^def(?:module|protocol|impl)\s+(.*)\s+do$/m, source, capture: :all_but_first) -> module

[module] ->
module
# Is it an erlang module?
[module] = Regex.run(~r/^-module\((.*)\)\.$/m, source, capture: :all_but_first) -> module

_ ->
[module] = Regex.run(~r/^-(?:module|protocol|impl)\((.*)\)\.$/m, source, capture: :all_but_first)
module
# Something else?
true -> "Unknown module"
end
end

Expand Down

0 comments on commit 9c04ab2

Please sign in to comment.