Open Wigny opened 2 weeks ago
Rewriting the code to the following avoids the warning, but I'm unsure if that is the right solution.
defmodule Test do
for n <- 1..4 do
def unquote(:erlang.binary_to_atom("fun_#{n}"))(), do: unquote(n)
end
end
Environment
mix credo -v
): 1.7.7-ref.dependabot-hex-gettext-0.26.1.58e9c1b08elixir -v
): Elixir 1.17.2 (compiled with Erlang/OTP 26)What were you trying to do?
Running the
Credo.Check.Warning.UnsafeToAtom
check (mix credo -c Credo.Check.Warning.UnsafeToAtom
) is reporting right now issues for dynamically created atoms passed tounquote()
.Expected outcome
AFAIK dynamically created atoms passed to
unquote()
are generated in compile time and thus should not be reported by this check, given they cannot be exploited in runtime. Thus the following code should not emit the check warning:Actual outcome
Running the check on the code above returns