diff --git a/.dialyzer_ignore.exs b/.dialyzer_ignore.exs index acde5b83f..11bb9da67 100644 --- a/.dialyzer_ignore.exs +++ b/.dialyzer_ignore.exs @@ -1,4 +1,7 @@ [ {"lib/x509/certificate.ex", "Unknown type: X509.ASN1.record/1."}, - {"lib/x509/certificate/extension.ex", "Unknown type: X509.ASN1.record/1."} + {"lib/x509/certificate/extension.ex", "Unknown type: X509.ASN1.record/1."}, + {"lib/nerves_hub/deployments/orchestrator.ex", :unmatched_return, 1}, + {"lib/nerves_hub_web/channels/device_channel.ex", :unmatched_return, 1}, + {"lib/nerves_hub_web/channels/device_socket.ex", :unmatched_return, 1} ] diff --git a/lib/nerves_hub/application.ex b/lib/nerves_hub/application.ex index 088bea481..ed2d83783 100644 --- a/lib/nerves_hub/application.ex +++ b/lib/nerves_hub/application.ex @@ -51,7 +51,7 @@ defmodule NervesHub.Application do defp setup_open_telemetry() do if System.get_env("ECTO_IPV6") do - :httpc.set_option(:ipfamily, :inet6fb4) + :ok = :httpc.set_option(:ipfamily, :inet6fb4) end :ok = NervesHub.Telemetry.Customizations.setup() diff --git a/lib/nerves_hub/extensions.ex b/lib/nerves_hub/extensions.ex index 7bdc4e9e6..3c76943af 100644 --- a/lib/nerves_hub/extensions.ex +++ b/lib/nerves_hub/extensions.ex @@ -37,12 +37,12 @@ defmodule NervesHub.Extensions do @doc """ Get list of supported extensions as atoms with descriptive text. """ - @spec list() :: list(extension()) + @spec list() :: [:geo | :health, ...] def list do @supported_extensions end - @spec module(extension()) :: module() + @spec module(extension()) :: NervesHub.Extensions.Geo | NervesHub.Extensions.Health def module(:health), do: NervesHub.Extensions.Health def module(:geo), do: NervesHub.Extensions.Geo diff --git a/lib/nerves_hub/extensions/health.ex b/lib/nerves_hub/extensions/health.ex index e0558ea6a..4161b0abd 100644 --- a/lib/nerves_hub/extensions/health.ex +++ b/lib/nerves_hub/extensions/health.ex @@ -67,7 +67,7 @@ defmodule NervesHub.Extensions.Health do {:health_report, Devices.save_device_health(device_health)}, {:metrics_report, {:ok, _}} <- {:metrics_report, Metrics.save_metrics(socket.assigns.device.id, metrics)} do - device_internal_broadcast!(socket.assigns.device, "health_check_report", %{}) + :ok = device_internal_broadcast!(socket.assigns.device, "health_check_report", %{}) else {:health_report, {:error, err}} -> Logger.warning("Failed to save health check data: #{inspect(err)}") @@ -96,7 +96,7 @@ defmodule NervesHub.Extensions.Health do end def request_health_check(device) do - device_internal_broadcast!(device, "health:check", %{}) + :ok = device_internal_broadcast!(device, "health:check", %{}) end defp device_internal_broadcast!(device, event, payload) do diff --git a/lib/nerves_hub_web/channels/extensions_channel.ex b/lib/nerves_hub_web/channels/extensions_channel.ex index 67f8ad077..b721b9860 100644 --- a/lib/nerves_hub_web/channels/extensions_channel.ex +++ b/lib/nerves_hub_web/channels/extensions_channel.ex @@ -20,7 +20,7 @@ defmodule NervesHubWeb.ExtensionsChannel do end topic = "device:#{socket.assigns.device.id}:extensions" - PubSub.subscribe(NervesHub.PubSub, topic) + :ok = PubSub.subscribe(NervesHub.PubSub, topic) {:ok, attach_list, socket} end @@ -95,7 +95,7 @@ defmodule NervesHubWeb.ExtensionsChannel do @impl Phoenix.Channel def handle_info(:init_extensions, socket) do topic = "product:#{socket.assigns.device.product.id}:extensions" - PubSub.subscribe(NervesHub.PubSub, topic) + :ok = PubSub.subscribe(NervesHub.PubSub, topic) {:noreply, socket} end diff --git a/lib/nerves_hub_web/channels/user_console_channel.ex b/lib/nerves_hub_web/channels/user_console_channel.ex index 021760e08..0f9c7c806 100644 --- a/lib/nerves_hub_web/channels/user_console_channel.ex +++ b/lib/nerves_hub_web/channels/user_console_channel.ex @@ -64,13 +64,13 @@ defmodule NervesHubWeb.UserConsoleChannel do end def terminate(_reason, socket) do - if socket.joined do - _ = + _ = + if socket.joined do broadcast(socket, "message", %{ name: socket.assigns.user.name, event: "closed the console" }) - end + end socket end diff --git a/lib/nerves_hub_web/live/dashboard/index.ex b/lib/nerves_hub_web/live/dashboard/index.ex index a53dfd0f9..20e312cf5 100644 --- a/lib/nerves_hub_web/live/dashboard/index.ex +++ b/lib/nerves_hub_web/live/dashboard/index.ex @@ -145,14 +145,16 @@ defmodule NervesHubWeb.Live.Dashboard.Index do defp get_connection_status(_), do: "offline" defp refresh_after(socket, delay) do - if socket.assigns.next_timer do - Process.cancel_timer(socket.assigns.next_timer) - end - + maybe_cancel_timer(socket.assigns.next_timer) timer = Process.send_after(self(), :refresh_device_list, delay) assign(socket, :next_timer, timer) end + def maybe_cancel_timer(timer) do + _ = if timer, do: Process.cancel_timer(timer) + :ok + end + defp time do System.monotonic_time(:millisecond) end