From 36175be74e1efafc4fd66516cfa7ade85229df17 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Sun, 11 Jan 2026 15:01:57 -0600 Subject: [PATCH] fix dialyzer and credo --- .../controllers/api/agent_controller.ex | 7 ++++--- lib/towerops_web/plugs/agent_auth.ex | 16 +++++++++------- test/towerops/snmp/profiles/mikrotik_test.exs | 6 +++--- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/lib/towerops_web/controllers/api/agent_controller.ex b/lib/towerops_web/controllers/api/agent_controller.ex index 058b75b0..e9b591c2 100644 --- a/lib/towerops_web/controllers/api/agent_controller.ex +++ b/lib/towerops_web/controllers/api/agent_controller.ex @@ -54,9 +54,10 @@ defmodule ToweropsWeb.Api.AgentController do Map.get(params, "metrics", []) end - Task.start(fn -> - process_metrics(agent_token, metrics) - end) + _ = + Task.start(fn -> + process_metrics(agent_token, metrics) + end) json(conn, %{status: "accepted", received: length(metrics)}) end diff --git a/lib/towerops_web/plugs/agent_auth.ex b/lib/towerops_web/plugs/agent_auth.ex index 2e654027..08fc32d4 100644 --- a/lib/towerops_web/plugs/agent_auth.ex +++ b/lib/towerops_web/plugs/agent_auth.ex @@ -46,14 +46,16 @@ defmodule ToweropsWeb.Plugs.AgentAuth do parent = self() - Task.start(fn -> - # Allow this task to use the test database sandbox - if Application.get_env(:towerops, :sql_sandbox) do - Sandbox.allow(Towerops.Repo, parent, self()) - end + _ = + Task.start(fn -> + # Allow this task to use the test database sandbox + _ = + if Application.get_env(:towerops, :sql_sandbox) do + Sandbox.allow(Towerops.Repo, parent, self()) + end - Agents.update_agent_token_heartbeat(agent_token.id, ip) - end) + _ = Agents.update_agent_token_heartbeat(agent_token.id, ip) + end) conn end diff --git a/test/towerops/snmp/profiles/mikrotik_test.exs b/test/towerops/snmp/profiles/mikrotik_test.exs index 82426a88..f7efe657 100644 --- a/test/towerops/snmp/profiles/mikrotik_test.exs +++ b/test/towerops/snmp/profiles/mikrotik_test.exs @@ -198,15 +198,15 @@ defmodule Towerops.Snmp.Profiles.MikrotikTest do # Should have temperature sensors temp_sensors = Enum.filter(sensors, &String.contains?(&1.sensor_type, "temperature")) - assert length(temp_sensors) > 0 + assert temp_sensors != [] # Should have voltage sensors voltage_sensors = Enum.filter(sensors, &String.contains?(&1.sensor_type, "voltage")) - assert length(voltage_sensors) > 0 + assert voltage_sensors != [] # Should have fan sensors fan_sensors = Enum.filter(sensors, &(&1.sensor_type == "fan1")) - assert length(fan_sensors) > 0 + assert fan_sensors != [] # Check one sensor in detail cpu_temp = Enum.find(sensors, &(&1.sensor_type == "cpu_temperature"))