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
This commit is contained in:
parent
7bdf21fb53
commit
281aef095c
7 changed files with 18 additions and 20 deletions
|
|
@ -5,6 +5,8 @@ defmodule Aprsme.SpatialPubSub do
|
||||||
"""
|
"""
|
||||||
use GenServer
|
use GenServer
|
||||||
|
|
||||||
|
require Logger
|
||||||
|
|
||||||
# Grid size in degrees for spatial indexing
|
# Grid size in degrees for spatial indexing
|
||||||
@grid_size 1.0
|
@grid_size 1.0
|
||||||
# Maximum number of concurrent clients
|
# Maximum number of concurrent clients
|
||||||
|
|
@ -252,7 +254,6 @@ defmodule Aprsme.SpatialPubSub do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp normalize_bounds(invalid) do
|
defp normalize_bounds(invalid) do
|
||||||
require Logger
|
|
||||||
Logger.warning("normalize_bounds called with invalid bounds map: #{inspect(invalid)}")
|
Logger.warning("normalize_bounds called with invalid bounds map: #{inspect(invalid)}")
|
||||||
%{north: 0.0, south: 0.0, east: 0.0, west: 0.0}
|
%{north: 0.0, south: 0.0, east: 0.0, west: 0.0}
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -14,15 +14,16 @@ defmodule Aprsme.WeatherCache do
|
||||||
The table is typically created in application.ex alongside other ETS tables.
|
The table is typically created in application.ex alongside other ETS tables.
|
||||||
"""
|
"""
|
||||||
def setup do
|
def setup do
|
||||||
if :ets.whereis(@cache_name) == :undefined do
|
_table =
|
||||||
:ets.new(@cache_name, [
|
if :ets.whereis(@cache_name) == :undefined do
|
||||||
:named_table,
|
:ets.new(@cache_name, [
|
||||||
:public,
|
:named_table,
|
||||||
:set,
|
:public,
|
||||||
read_concurrency: true,
|
:set,
|
||||||
write_concurrency: true
|
read_concurrency: true,
|
||||||
])
|
write_concurrency: true
|
||||||
end
|
])
|
||||||
|
end
|
||||||
|
|
||||||
:ok
|
:ok
|
||||||
rescue
|
rescue
|
||||||
|
|
|
||||||
|
|
@ -25,9 +25,10 @@ defmodule AprsmeWeb.PacketsLive.CallsignView do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp subscribe_if_connected(socket, callsign) do
|
defp subscribe_if_connected(socket, callsign) do
|
||||||
if connected?(socket) do
|
_ =
|
||||||
Phoenix.PubSub.subscribe(Aprsme.PubSub, "packets:#{callsign}")
|
if connected?(socket) do
|
||||||
end
|
Phoenix.PubSub.subscribe(Aprsme.PubSub, "packets:#{callsign}")
|
||||||
|
end
|
||||||
|
|
||||||
socket
|
socket
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,6 @@ defmodule Aprsme.DeviceIdentificationTest do
|
||||||
describe "known_manufacturers/0" do
|
describe "known_manufacturers/0" do
|
||||||
test "returns list of known manufacturers" do
|
test "returns list of known manufacturers" do
|
||||||
manufacturers = DeviceIdentification.known_manufacturers()
|
manufacturers = DeviceIdentification.known_manufacturers()
|
||||||
assert is_list(manufacturers)
|
|
||||||
assert "Kenwood" in manufacturers
|
assert "Kenwood" in manufacturers
|
||||||
assert "Yaesu" in manufacturers
|
assert "Yaesu" in manufacturers
|
||||||
assert "Byonics" in manufacturers
|
assert "Byonics" in manufacturers
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ defmodule Aprsme.PacketReplayTest do
|
||||||
user_id = "test_user"
|
user_id = "test_user"
|
||||||
|
|
||||||
assert_raise FunctionClauseError, fn ->
|
assert_raise FunctionClauseError, fn ->
|
||||||
apply(PacketReplay, :update_filters, [user_id, %{callsign: "N0CALL"}])
|
PacketReplay.update_filters(user_id, %{callsign: "N0CALL"})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,6 @@ defmodule Aprsme.PromExTest do
|
||||||
{:ok, plugins: Aprsme.PromEx.plugins()}
|
{:ok, plugins: Aprsme.PromEx.plugins()}
|
||||||
end
|
end
|
||||||
|
|
||||||
test "is a list", %{plugins: plugins} do
|
|
||||||
assert is_list(plugins)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "includes the built-in PromEx plugins", %{plugins: plugins} do
|
test "includes the built-in PromEx plugins", %{plugins: plugins} do
|
||||||
modules = plugin_modules(plugins)
|
modules = plugin_modules(plugins)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ defmodule AprsmeWeb.TelemetryTest do
|
||||||
describe "metrics/0" do
|
describe "metrics/0" do
|
||||||
test "returns a non-empty list of metric definitions" do
|
test "returns a non-empty list of metric definitions" do
|
||||||
metrics = Telemetry.metrics()
|
metrics = Telemetry.metrics()
|
||||||
assert is_list(metrics)
|
refute Enum.empty?(metrics)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "includes Phoenix endpoint, router, and live_view metrics" do
|
test "includes Phoenix endpoint, router, and live_view metrics" do
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue