Fix credo issues

- Remove trailing whitespace from comments
- Fix long line in packet_processor.ex
- Rename is_leader? to leader? following Elixir conventions
This commit is contained in:
Graham McIntire 2026-02-09 11:17:56 -06:00
parent ff06c13224
commit 81a4b7b815
No known key found for this signature in database
11 changed files with 21 additions and 20 deletions

View file

@ -203,7 +203,7 @@ defmodule Aprsme.Application do
# Removed - Exq configuration is now in runtime.exs
# defp exq_config do
# redis_url = System.get_env("REDIS_URL", "redis://localhost:6379")
#
#
# {Exq,
# name: Exq,
# host: parse_redis_host(redis_url),

View file

@ -26,7 +26,7 @@ defmodule Aprsme.Cluster.ConnectionManager do
@impl true
def handle_info(:check_initial_state, state) do
if Aprsme.Cluster.LeaderElection.is_leader?() do
if Aprsme.Cluster.LeaderElection.leader?() do
Logger.info("This node is the leader, starting APRS-IS connection")
start_aprs_connection()
{:noreply, %{state | connection_started: true}}

View file

@ -16,8 +16,8 @@ defmodule Aprsme.Cluster.LeaderElection do
GenServer.start_link(__MODULE__, opts, name: __MODULE__)
end
def is_leader? do
GenServer.call(__MODULE__, :is_leader?)
def leader? do
GenServer.call(__MODULE__, :leader?)
end
def current_leader do
@ -148,7 +148,7 @@ defmodule Aprsme.Cluster.LeaderElection do
end
@impl true
def handle_call(:is_leader?, _from, state) do
def handle_call(:leader?, _from, state) do
{:reply, state.is_leader, state}
end

View file

@ -12,7 +12,7 @@ defmodule Aprsme.Cluster.PacketDistributor do
# Only distribute if clustering is enabled and we're the leader
cluster_enabled = Application.get_env(:aprsme, :cluster_enabled, false)
if cluster_enabled and Aprsme.Cluster.LeaderElection.is_leader?() do
if cluster_enabled and Aprsme.Cluster.LeaderElection.leader?() do
# Broadcast to all nodes including self
Phoenix.PubSub.broadcast(
Aprsme.PubSub,

View file

@ -27,7 +27,7 @@ defmodule Aprsme.Cluster.PacketReceiver do
@impl true
def handle_info({:distributed_packet, packet}, state) do
# Only process if we're not the leader (leader already processed locally)
if !Aprsme.Cluster.LeaderElection.is_leader?() do
if !Aprsme.Cluster.LeaderElection.leader?() do
PacketDistributor.handle_distributed_packet({:distributed_packet, packet})
end

View file

@ -90,7 +90,7 @@ defmodule Aprsme.Packet do
field(:symbolcode, :string)
field(:messaging, :integer)
# Additional weather fields
# Additional weather fields
field(:rain_midnight, :float)
field(:has_weather, :boolean, default: false)

View file

@ -180,7 +180,7 @@ defmodule AprsmeWeb.MapLive.HistoricalLoader do
recent_packets = Packets.get_recent_packets(params)
Logger.debug("HistoricalLoader: Got #{length(recent_packets)} packets")
# If tracking a callsign and this is the first batch, ensure we always include
# If tracking a callsign and this is the first batch, ensure we always include
# the most recent packet for that callsign, even if it's older than the time filter
if socket.assigns.tracked_callsign != "" and batch_offset == 0 do
latest_packet = Packets.get_latest_packet_for_callsign(socket.assigns.tracked_callsign)

View file

@ -69,7 +69,8 @@ defmodule AprsmeWeb.MapLive.PacketProcessor do
# Significant movement detected (more than 50 meters), update the marker
handle_valid_postgres_packet(packet, lat, lon, socket)
else
# Just GPS drift (less than 50 meters) or invalid coordinates, update the packet data but don't send visual update
# Just GPS drift (less than 50 meters) or invalid coordinates,
# update the packet data but don't send visual update
new_visible_packets = Map.put(socket.assigns.visible_packets, callsign_key, packet)
assign(socket, :visible_packets, new_visible_packets)
end

View file

@ -219,7 +219,7 @@ defmodule Aprsme.Cluster.ConnectionManagerTest do
end
test "handles IsSupervisor already started error", %{pid: pid} do
# The APRS-IS connection is disabled in test environment,
# The APRS-IS connection is disabled in test environment,
# but we can still test that the ConnectionManager handles errors gracefully
# Try to become leader

View file

@ -58,7 +58,7 @@ defmodule Aprsme.Cluster.LeaderElectionTest do
end
test "elects itself as leader when clustering is disabled", %{pid: _pid} do
assert LeaderElection.is_leader?() == true
assert LeaderElection.leader?() == true
assert LeaderElection.current_leader() == node()
end
@ -67,7 +67,7 @@ defmodule Aprsme.Cluster.LeaderElectionTest do
end
end
describe "is_leader?/0" do
describe "leader?/0" do
setup do
Application.put_env(:aprsme, :cluster_enabled, false)
{:ok, _pid} = LeaderElection.start_link([])
@ -76,7 +76,7 @@ defmodule Aprsme.Cluster.LeaderElectionTest do
end
test "returns leadership status" do
assert is_boolean(LeaderElection.is_leader?())
assert is_boolean(LeaderElection.leader?())
end
end
@ -137,7 +137,7 @@ defmodule Aprsme.Cluster.LeaderElectionTest do
Process.sleep(200)
# Verify it's the leader
assert LeaderElection.is_leader?() == true
assert LeaderElection.leader?() == true
# Stop the process
GenServer.stop(pid)
@ -151,13 +151,13 @@ defmodule Aprsme.Cluster.LeaderElectionTest do
{:ok, _pid} = LeaderElection.start_link([])
# Initial state - might not be leader yet
_initial_leader = LeaderElection.is_leader?()
_initial_leader = LeaderElection.leader?()
# Wait for periodic check
Process.sleep(6000)
# Should still be able to query leadership
current_leader = LeaderElection.is_leader?()
current_leader = LeaderElection.leader?()
assert is_boolean(current_leader)
# In non-clustered mode, should become leader
@ -210,7 +210,7 @@ defmodule Aprsme.Cluster.LeaderElectionTest do
Process.sleep(500)
# Should have taken over leadership
assert LeaderElection.is_leader?() == true
assert LeaderElection.leader?() == true
end
end
@ -232,7 +232,7 @@ defmodule Aprsme.Cluster.LeaderElectionTest do
Process.sleep(3000)
# Should eventually attempt election
assert is_boolean(LeaderElection.is_leader?())
assert is_boolean(LeaderElection.leader?())
end
end

View file

@ -97,7 +97,7 @@ defmodule Aprsme.EnhancedParserTest do
result = Packet.extract_additional_data(attrs)
# PHG 5430: power=5^2=25W, height=4->160ft, gain=3dB, dir=0->omni
# PHG 5430: power=5^2=25W, height=4->160ft, gain=3dB, dir=0->omni
assert result[:phg_power] == 25
assert result[:phg_height] == 160
assert result[:phg_gain] == 3