From fd7849dfb7f6527f17f874fa6f7f55c6869805e0 Mon Sep 17 00:00:00 2001 From: Victor Martinez <49537445+JasterV@users.noreply.github.com> Date: Fri, 29 Mar 2024 16:24:26 +0100 Subject: [PATCH] make credo happy --- lib/intisync/puid.ex | 2 +- lib/intisync/session_pubsub.ex | 4 ++++ lib/intisync/session_server.ex | 17 +++++++++++------ lib/intisync/sessions_supervisor.ex | 3 +++ lib/intisync_web/channels/live_view_monitor.ex | 3 +++ .../components/device_card_component.ex | 3 +++ lib/intisync_web/live/remote_live.ex | 2 +- 7 files changed, 26 insertions(+), 8 deletions(-) diff --git a/lib/intisync/puid.ex b/lib/intisync/puid.ex index b489ae4..9fa6bde 100644 --- a/lib/intisync/puid.ex +++ b/lib/intisync/puid.ex @@ -1,5 +1,5 @@ defmodule Intisync.Puid do - @doc """ + @moduledoc """ Generate Probably unique identifiers """ use Puid diff --git a/lib/intisync/session_pubsub.ex b/lib/intisync/session_pubsub.ex index c2fc00e..af54287 100644 --- a/lib/intisync/session_pubsub.ex +++ b/lib/intisync/session_pubsub.ex @@ -1,4 +1,8 @@ defmodule Intisync.SessionPubSub do + @moduledoc """ + Provides function to publish/subscribe to IntiSync.PubSub topics + """ + def broadcast!(session_id, topic, event, payload) do topic = "#{topic}:#{event}:#{session_id}" payload = %{payload: payload, topic: topic} diff --git a/lib/intisync/session_server.ex b/lib/intisync/session_server.ex index 5adcd5c..300090c 100644 --- a/lib/intisync/session_server.ex +++ b/lib/intisync/session_server.ex @@ -1,7 +1,12 @@ defmodule Intisync.SessionServer do - alias Intisync.SessionPubSub + @moduledoc """ + Contains the business logic of a session. + It is the source of truth of the session state. + """ use GenServer + alias Intisync.SessionPubSub + def init(session_id) do {:ok, %{ @@ -47,8 +52,8 @@ defmodule Intisync.SessionServer do GenServer.call(pid, {:get_devices}) end - def is_full?(pid) do - GenServer.call(pid, {:is_full?}) + def full?(pid) do + GenServer.call(pid, {:full?}) end def handle_call({:get_id}, _from, state) do @@ -59,10 +64,10 @@ defmodule Intisync.SessionServer do {:reply, state.devices, state} end - def handle_call({:is_full?}, _from, state) do - is_full? = state.remote_connection_status == :connected + def handle_call({:full?}, _from, state) do + full? = state.remote_connection_status == :connected - {:reply, is_full?, state} + {:reply, full?, state} end def handle_call({:device_connected, index, device}, _from, state) do diff --git a/lib/intisync/sessions_supervisor.ex b/lib/intisync/sessions_supervisor.ex index cfd2bdc..939b9a0 100644 --- a/lib/intisync/sessions_supervisor.ex +++ b/lib/intisync/sessions_supervisor.ex @@ -1,4 +1,7 @@ defmodule Intisync.SessionsSupervisor do + @moduledoc """ + DynamicSupervisor responsible to manage SessionServers + """ use DynamicSupervisor alias Intisync.SessionServer diff --git a/lib/intisync_web/channels/live_view_monitor.ex b/lib/intisync_web/channels/live_view_monitor.ex index e2f2f68..b76cb64 100644 --- a/lib/intisync_web/channels/live_view_monitor.ex +++ b/lib/intisync_web/channels/live_view_monitor.ex @@ -1,4 +1,7 @@ defmodule IntisyncWeb.LiveViewMonitor do + @moduledoc """ + Monitors LiveView processes and calls their `unmount` functions when they die + """ use GenServer def start_link(init_arg) do diff --git a/lib/intisync_web/components/device_card_component.ex b/lib/intisync_web/components/device_card_component.ex index e8d6008..50b6bb5 100644 --- a/lib/intisync_web/components/device_card_component.ex +++ b/lib/intisync_web/components/device_card_component.ex @@ -1,4 +1,7 @@ defmodule IntisyncWeb.DeviceCardComponent do + @moduledoc """ + Renders a device card + """ use Phoenix.Component import IntisyncWeb.CoreComponents diff --git a/lib/intisync_web/live/remote_live.ex b/lib/intisync_web/live/remote_live.ex index c11a4b4..1467ee7 100644 --- a/lib/intisync_web/live/remote_live.ex +++ b/lib/intisync_web/live/remote_live.ex @@ -52,7 +52,7 @@ defmodule IntisyncWeb.RemoteLive do {:error, :not_found} pid -> - if SessionServer.is_full?(pid) do + if SessionServer.full?(pid) do {:error, :unauthorized} else {:ok, pid}