From 281aef095c1f9f99f3ae016b1efc69cce9c4a86d Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Fri, 17 Jul 2026 16:41:15 -0500 Subject: [PATCH] fix: resolve all credo warnings and pre-existing dialyzer errors - Move require Logger to module top level in SpatialPubSub - Replace weak is_list assertions with stronger checks - Remove redundant 'is a list' test in PromEx tests - Replace apply/3 with direct function call in packet_replay test - Fix unmatched_return in weather_cache.ex and callsign_view.ex --- lib/aprsme/spatial_pubsub.ex | 3 ++- lib/aprsme/weather_cache.ex | 19 ++++++++++--------- .../live/packets_live/callsign_view.ex | 7 ++++--- test/aprsme/device_identification_test.exs | 1 - test/aprsme/packet_replay_test.exs | 2 +- test/aprsme/prom_ex_test.exs | 4 ---- test/aprsme_web/telemetry_test.exs | 2 +- 7 files changed, 18 insertions(+), 20 deletions(-) diff --git a/lib/aprsme/spatial_pubsub.ex b/lib/aprsme/spatial_pubsub.ex index 64f89c7..16f3e40 100644 --- a/lib/aprsme/spatial_pubsub.ex +++ b/lib/aprsme/spatial_pubsub.ex @@ -5,6 +5,8 @@ defmodule Aprsme.SpatialPubSub do """ use GenServer + require Logger + # Grid size in degrees for spatial indexing @grid_size 1.0 # Maximum number of concurrent clients @@ -252,7 +254,6 @@ defmodule Aprsme.SpatialPubSub do end defp normalize_bounds(invalid) do - require Logger Logger.warning("normalize_bounds called with invalid bounds map: #{inspect(invalid)}") %{north: 0.0, south: 0.0, east: 0.0, west: 0.0} end diff --git a/lib/aprsme/weather_cache.ex b/lib/aprsme/weather_cache.ex index 5ccc769..a64d3cf 100644 --- a/lib/aprsme/weather_cache.ex +++ b/lib/aprsme/weather_cache.ex @@ -14,15 +14,16 @@ defmodule Aprsme.WeatherCache do The table is typically created in application.ex alongside other ETS tables. """ def setup do - if :ets.whereis(@cache_name) == :undefined do - :ets.new(@cache_name, [ - :named_table, - :public, - :set, - read_concurrency: true, - write_concurrency: true - ]) - end + _table = + if :ets.whereis(@cache_name) == :undefined do + :ets.new(@cache_name, [ + :named_table, + :public, + :set, + read_concurrency: true, + write_concurrency: true + ]) + end :ok rescue diff --git a/lib/aprsme_web/live/packets_live/callsign_view.ex b/lib/aprsme_web/live/packets_live/callsign_view.ex index 6bb62b0..22c3355 100644 --- a/lib/aprsme_web/live/packets_live/callsign_view.ex +++ b/lib/aprsme_web/live/packets_live/callsign_view.ex @@ -25,9 +25,10 @@ defmodule AprsmeWeb.PacketsLive.CallsignView do end defp subscribe_if_connected(socket, callsign) do - if connected?(socket) do - Phoenix.PubSub.subscribe(Aprsme.PubSub, "packets:#{callsign}") - end + _ = + if connected?(socket) do + Phoenix.PubSub.subscribe(Aprsme.PubSub, "packets:#{callsign}") + end socket end diff --git a/test/aprsme/device_identification_test.exs b/test/aprsme/device_identification_test.exs index 5431394..7328581 100644 --- a/test/aprsme/device_identification_test.exs +++ b/test/aprsme/device_identification_test.exs @@ -60,7 +60,6 @@ defmodule Aprsme.DeviceIdentificationTest do describe "known_manufacturers/0" do test "returns list of known manufacturers" do manufacturers = DeviceIdentification.known_manufacturers() - assert is_list(manufacturers) assert "Kenwood" in manufacturers assert "Yaesu" in manufacturers assert "Byonics" in manufacturers diff --git a/test/aprsme/packet_replay_test.exs b/test/aprsme/packet_replay_test.exs index 106c39a..93c4b49 100644 --- a/test/aprsme/packet_replay_test.exs +++ b/test/aprsme/packet_replay_test.exs @@ -58,7 +58,7 @@ defmodule Aprsme.PacketReplayTest do user_id = "test_user" assert_raise FunctionClauseError, fn -> - apply(PacketReplay, :update_filters, [user_id, %{callsign: "N0CALL"}]) + PacketReplay.update_filters(user_id, %{callsign: "N0CALL"}) end end end diff --git a/test/aprsme/prom_ex_test.exs b/test/aprsme/prom_ex_test.exs index da56d2b..c558a56 100644 --- a/test/aprsme/prom_ex_test.exs +++ b/test/aprsme/prom_ex_test.exs @@ -8,10 +8,6 @@ defmodule Aprsme.PromExTest do {:ok, plugins: Aprsme.PromEx.plugins()} end - test "is a list", %{plugins: plugins} do - assert is_list(plugins) - end - test "includes the built-in PromEx plugins", %{plugins: plugins} do modules = plugin_modules(plugins) diff --git a/test/aprsme_web/telemetry_test.exs b/test/aprsme_web/telemetry_test.exs index 7b84dd7..c3e46aa 100644 --- a/test/aprsme_web/telemetry_test.exs +++ b/test/aprsme_web/telemetry_test.exs @@ -6,7 +6,7 @@ defmodule AprsmeWeb.TelemetryTest do describe "metrics/0" do test "returns a non-empty list of metric definitions" do metrics = Telemetry.metrics() - assert is_list(metrics) + refute Enum.empty?(metrics) end test "includes Phoenix endpoint, router, and live_view metrics" do