credo
credo copied to clipboard
"Most of the time you are using the multi-alias/require/import/use syntax..." with compile_env
Environment
- Credo version (
mix credo -v): 1.7.4-ref.np-interpret-user-ops.b900d15036+uncommittedchanges - Erlang/Elixir version (
elixir -v): Erlang/OTP 25 [erts-13.2.2.5] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1]
Elixir 1.14.5 (compiled with Erlang/OTP 25)
- Operating system: MacOS 14
What were you trying to do?
defmodule SomeModule do
alias A.B.Foo
...
case Application.compile_env(:app, SomeModule)[:use_bar] do
"true" ->
defp a() do
alias A.B.Bar
Bar.f()
end
_ ->
defp a(), do: nil
end
end
Expected outcome
No warnings from credo
Actual outcome
Consistency
┃
┃ [C] ↗ Most of the time you are using the multi-alias/require/import/use syntax, but here you are using
┃ multiple single directives
┃ <path>
Hi, I can't reproduce this.
I have used this code:
defmodule SomeModule do
alias A.B.Foo
case Application.compile_env(:app, SomeModule)[:use_bar] do
"true" ->
defp a() do
alias A.B.Bar
Bar.f()
end
_ ->
defp a(), do: nil
end
end
Can you provide any additional details or create a minimal reproducible example?
Here it is: https://github.com/sl1depengwyn/credo-multi-alias-example/tree/main
Thanks for reporting this 😀 It is now fixed on master.
You can try this by setting the Credo dep to
{:credo, github: "rrrene/credo"}
Please report back if your issue is solved! 👍
This is live in v1.7.6 🎉