Warning: this check/guard will always yield the same result. Should I do this differently?

Do you have a special reason to use that module attribute? Some name it an anti-pattern, discussion on using (secret) config info in this way and alternatives you can find here:

https://medium.com/nebo-15/runtime-configuration-migrations-and-deployment-for-elixir-applications-6295b892fa6a

When you do not use the module attribute (see links above) you can write:

  defmodule Foo do
    def check(secret), do: if Application.get_env(:foo, :secret) in [secret, nil], do: :ok, else: :error
  end

otherwise

  defmodule Foo do
    @secret Application.get_env(:foo, :secret)
    def check(secret), do: if @secret in [secret, nil], do: :ok, else: :error
  end