Disable detection of undefined-function-warnings partially on Elixir < 1.13

This commit is contained in:
Marcel Otto 2022-06-19 22:16:47 +02:00
parent 6109ec66e5
commit c58ffd383b
2 changed files with 18 additions and 10 deletions

View file

@ -26,6 +26,10 @@ jobs:
- pair: - pair:
elixir: 1.12.3 elixir: 1.12.3
otp: 24.3 otp: 24.3
# Although Elixir 1.12 supports this feature, we're expecting errors since the code to suppress
# undefined-function-warnings on RDF.Graph.build blocks relies on Elixir 1.13 and is disabled
# partially on older versions.
no-warnings-as-errors: true
- pair: - pair:
elixir: 1.13.3 elixir: 1.13.3
otp: 23.3 otp: 23.3

View file

@ -276,17 +276,21 @@ defmodule RDF.Graph.Builder do
String.to_atom(short) String.to_atom(short)
end end
defp extract_non_strict_ns(block) do if Version.match?(System.version(), ">= 1.13.0") do
modules = defp extract_non_strict_ns(block) do
block modules =
|> Macro.prewalker() block
|> Enum.reduce([], fn |> Macro.prewalker()
{:__aliases__, _, mod}, modules -> [Module.concat(mod) | modules] |> Enum.reduce([], fn
_, modules -> modules {:__aliases__, _, mod}, modules -> [Module.concat(mod) | modules]
end) _, modules -> modules
|> Enum.uniq() end)
|> Enum.uniq()
for module <- modules, non_strict_vocab_namespace?(module), do: module for module <- modules, non_strict_vocab_namespace?(module), do: module
end
else
defp extract_non_strict_ns(_), do: []
end end
defp non_strict_vocab_namespace?(mod) do defp non_strict_vocab_namespace?(mod) do