fix: resolve all dialyzer warnings — unmatched returns, pattern mismatches, and Mix.Task PLT entries
This commit is contained in:
parent
20c3eab1c1
commit
a9827f245e
5 changed files with 22 additions and 13 deletions
|
|
@ -37,6 +37,7 @@
|
|||
# in the dialyzer PLT; also the aprs library's return type is inferred incorrectly from
|
||||
# the compiled beam without full type specs
|
||||
{"lib/mix/tasks/aprs.parse_file.ex"},
|
||||
{"lib/mix/tasks/aprsme.user_role.ex"},
|
||||
|
||||
# Mix.Task.Compiler PLT limitations: same root cause — Mix.* functions and the
|
||||
# Mix.Task.Compiler.Diagnostic struct aren't in the dialyzer PLT.
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@ defmodule Aprsme.DeploymentNotifier do
|
|||
|
||||
@impl true
|
||||
def init(_opts) do
|
||||
if System.get_env("DEPLOYED_AT"),
|
||||
do: :ok = Process.send_after(self(), :notify_deployment, 10_000),
|
||||
else: :ok
|
||||
_ =
|
||||
if System.get_env("DEPLOYED_AT"),
|
||||
do: Process.send_after(self(), :notify_deployment, 10_000)
|
||||
|
||||
{:ok, %{}}
|
||||
end
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ defmodule AprsmeWeb.MapLive.Subscriptions do
|
|||
def teardown(socket) do
|
||||
_teardown_connection_monitor(socket)
|
||||
_teardown_spatial(socket)
|
||||
_teardown_all_timers(socket)
|
||||
_ = _teardown_all_timers(socket)
|
||||
_teardown_batch_tasks(socket)
|
||||
:ok
|
||||
end
|
||||
|
|
@ -100,9 +100,9 @@ defmodule AprsmeWeb.MapLive.Subscriptions do
|
|||
end
|
||||
|
||||
defp _teardown_all_timers(socket) do
|
||||
cancel_if_exists(socket.assigns[:buffer_timer])
|
||||
cancel_if_exists(socket.assigns[:bounds_update_timer])
|
||||
cancel_if_exists(socket.assigns[:hover_end_timer])
|
||||
_ = cancel_if_exists(socket.assigns[:buffer_timer])
|
||||
_ = cancel_if_exists(socket.assigns[:bounds_update_timer])
|
||||
_ = cancel_if_exists(socket.assigns[:hover_end_timer])
|
||||
end
|
||||
|
||||
defp cancel_if_exists(nil), do: :ok
|
||||
|
|
|
|||
|
|
@ -422,7 +422,7 @@ defmodule AprsmeWeb.StatusLive.Index do
|
|||
_ ->
|
||||
# Fallback to direct query if cache miss
|
||||
status = get_aprs_status()
|
||||
Aprsme.Cache.put(:query_cache, "aprs_status", status, ttl: Aprsme.Cache.to_timeout(second: 10))
|
||||
_ = Aprsme.Cache.put(:query_cache, "aprs_status", status, ttl: Aprsme.Cache.to_timeout(second: 10))
|
||||
status
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -11,21 +11,29 @@ defmodule Mix.Tasks.Aprsme.UserRole do
|
|||
|
||||
@impl Mix.Task
|
||||
def run([email, role_name]) when role_name in ["user", "admin"] do
|
||||
Mix.Task.run("app.start")
|
||||
_ = Application.ensure_all_started(:aprsme)
|
||||
|
||||
case Aprsme.Accounts.get_user_by_email(email) do
|
||||
nil ->
|
||||
Mix.raise("No user found with email #{email}")
|
||||
IO.puts(:stderr, "Error: No user found with email #{email}")
|
||||
System.halt(1)
|
||||
|
||||
user ->
|
||||
role = String.to_existing_atom(role_name)
|
||||
|
||||
case Aprsme.Accounts.set_user_role(user, role) do
|
||||
{:ok, _user} -> Mix.shell().info("Set #{email} role to #{role_name}")
|
||||
{:error, changeset} -> Mix.raise("Could not update role: #{inspect(changeset.errors)}")
|
||||
{:ok, _user} ->
|
||||
IO.puts("Set #{email} role to #{role_name}")
|
||||
|
||||
{:error, changeset} ->
|
||||
IO.puts(:stderr, "Error: Could not update role: #{inspect(changeset.errors)}")
|
||||
System.halt(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def run(_args), do: Mix.raise("Usage: mix aprsme.user_role EMAIL user|admin")
|
||||
def run(_args) do
|
||||
IO.puts(:stderr, "Usage: mix aprsme.user_role EMAIL user|admin")
|
||||
System.halt(1)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue