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

Fixes related to dialyzer warnings #1715

Merged
merged 2 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .dialyzer_ignore.exs
Original file line number Diff line number Diff line change
@@ -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}
nshoes marked this conversation as resolved.
Show resolved Hide resolved
]
2 changes: 1 addition & 1 deletion lib/nerves_hub/application.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions lib/nerves_hub/extensions.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions lib/nerves_hub/extensions/health.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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)}")
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/nerves_hub_web/channels/extensions_channel.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions lib/nerves_hub_web/channels/user_console_channel.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions lib/nerves_hub_web/live/dashboard/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
nshoes marked this conversation as resolved.
Show resolved Hide resolved

defp time do
System.monotonic_time(:millisecond)
end
Expand Down
Loading