# runtime.exs
if config_env() == :prod do
config :some_app, start_gen_server: true
end
Then in my application.ex I have
# application.ex
def start(_type, _args) do
[]
|> maybe_start_gen_server()
|> Supervisor.start_link(strategy: :one_for_one, name: MyApp.Supervisor)
end
defp maybe_start_gen_server(children) do
if Application.get_env(:some_app, :start_gen_server) do
children ++ [MyApp.SomeGenServer]
else
children
end
end
Running mix dialyzer --force-check; I get
Function maybe_start_gen_server/1 will never be called.
and there’s not any other error or warning regarding this.
I’ve actually tested and confirmed that it’s actually called and my GenServer is running properly on production. What might be wrong?
But still that’s inside the function maybe_start_gen_server so how is it possible for the function not to be called? In fact, I’d tested it and it was working on production env. Now I can’t test because of some other error but I’ll double check.
But only function inside my function is the Application.get_env. Maybe I am doing something else wrong but as I’d mentioned above I’d tested the GenServer and it was working. I still can’t double check though because of some DB issue. So I’ll update here once I double check.
Oh I didn’t know that, makes sense.
Still I have no idea why I get the warning when the function is private though.
I double checked it and it runs on production, meaning that the function is called.