Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Most of the time you are using the multi-alias/require/import/use syntax..." with compile_env #1117

Closed
sl1depengwyn opened this issue Mar 13, 2024 · 4 comments

Comments

@sl1depengwyn
Copy link

sl1depengwyn commented Mar 13, 2024

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>
@rrrene
Copy link
Owner

rrrene commented Mar 13, 2024

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?

@sl1depengwyn
Copy link
Author

@rrrene
Copy link
Owner

rrrene commented Mar 13, 2024

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! 👍

@rrrene
Copy link
Owner

rrrene commented May 9, 2024

This is live in v1.7.6 🎉

@rrrene rrrene closed this as completed May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants