diff --git a/config/runtime.exs b/config/runtime.exs index 2bc57bc5..e371c6de 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -264,7 +264,7 @@ config :logger, case config_env() do :prod -> "info" :dev -> "info" - :test -> "debug" + :test -> "warning" end ) ) diff --git a/lib/wanderer_app/cache.ex b/lib/wanderer_app/cache.ex index 27bf8e78..6fe017fa 100644 --- a/lib/wanderer_app/cache.ex +++ b/lib/wanderer_app/cache.ex @@ -45,7 +45,7 @@ defmodule WandererApp.Cache do def insert({id, key}, value, opts) when is_binary(id) and (is_binary(key) or is_atom(key)), do: insert("#{id}:#{key}", value, opts) - def insert(key, nil, opts) when is_binary(key) or is_atom(key), do: delete(key) + def insert(key, nil, _opts) when is_binary(key) or is_atom(key), do: delete(key) def insert(key, value, opts) when is_binary(key) or is_atom(key), do: put(key, value, opts) def insert_or_update(key, value, update_fn, opts \\ []) diff --git a/lib/wanderer_app/character/tracker.ex b/lib/wanderer_app/character/tracker.ex index 5fec14cc..97ca71ac 100644 --- a/lib/wanderer_app/character/tracker.ex +++ b/lib/wanderer_app/character/tracker.ex @@ -598,9 +598,6 @@ defmodule WandererApp.Character.Tracker do {:error, :skipped} end - - _ -> - {:error, :skipped} end _ -> @@ -799,7 +796,7 @@ defmodule WandererApp.Character.Tracker do corporation_id |> WandererApp.Esi.get_corporation_info() |> case do - {:ok, %{"name" => corporation_name, "ticker" => corporation_ticker} = corporation_info} -> + {:ok, %{"name" => corporation_name, "ticker" => corporation_ticker}} -> {:ok, character} = WandererApp.Character.get_character(character_id) @@ -1002,7 +999,7 @@ defmodule WandererApp.Character.Tracker do defp maybe_update_active_maps( %{character_id: character_id, active_maps: active_maps} = state, - %{map_id: map_id, track: true} = track_settings + %{map_id: map_id, track: true} ) do if not Enum.member?(active_maps, map_id) do WandererApp.Cache.put( diff --git a/lib/wanderer_app/character/tracker_pool_dynamic_supervisor.ex b/lib/wanderer_app/character/tracker_pool_dynamic_supervisor.ex index 34433a94..53a19186 100644 --- a/lib/wanderer_app/character/tracker_pool_dynamic_supervisor.ex +++ b/lib/wanderer_app/character/tracker_pool_dynamic_supervisor.ex @@ -89,14 +89,4 @@ defmodule WandererApp.Character.TrackerPoolDynamicSupervisor do end end - defp stop_child(uuid) do - case Registry.lookup(@registry, uuid) do - [{pid, _}] -> - GenServer.cast(pid, :stop) - - _ -> - Logger.warn("Unable to locate pool assigned to #{inspect(uuid)}") - :ok - end - end end diff --git a/lib/wanderer_app/character/tracking_config_utils.ex b/lib/wanderer_app/character/tracking_config_utils.ex index 3e08be87..523f48b4 100644 --- a/lib/wanderer_app/character/tracking_config_utils.ex +++ b/lib/wanderer_app/character/tracking_config_utils.ex @@ -38,7 +38,7 @@ defmodule WandererApp.Character.TrackingConfigUtils do %{id: "default", title: "Default", value: default_count} ] - {:ok, pools_count} = + {:ok, _pools_count} = Cachex.get( :esi_auth_cache, "configs_total_count" diff --git a/lib/wanderer_app/esi/api_client.ex b/lib/wanderer_app/esi/api_client.ex index 6013efac..a7fe571c 100644 --- a/lib/wanderer_app/esi/api_client.ex +++ b/lib/wanderer_app/esi/api_client.ex @@ -8,7 +8,6 @@ defmodule WandererApp.Esi.ApiClient do @ttl :timer.hours(1) @wanderrer_user_agent "(wanderer-industries@proton.me; +https://github.com/wanderer-industries/wanderer)" - @req_esi_options [base_url: "https://esi.evetech.net", finch: WandererApp.Finch] @cache_opts [cache: true] @retry_opts [retry: false, retry_log_level: :warning] @@ -74,7 +73,7 @@ defmodule WandererApp.Esi.ApiClient do |> Keyword.merge(@timeout_opts) ) - def get_routes_eve(hubs, origin, params, opts), + def get_routes_eve(hubs, origin, _params, _opts), do: {:ok, hubs @@ -101,33 +100,6 @@ defmodule WandererApp.Esi.ApiClient do end end)} - defp do_get_routes_eve(origin, destination, params, opts) do - esi_params = - Map.merge(params, %{ - connections: params.connections |> Enum.join(","), - avoid: params.avoid |> Enum.join(",") - }) - - do_get( - "/route/#{origin}/#{destination}/?#{esi_params |> Plug.Conn.Query.encode()}", - opts, - @cache_opts - ) - |> case do - {:ok, result} -> - %{ - "origin" => origin, - "destination" => destination, - "systems" => result, - "success" => true - } - - error -> - Logger.warning("Error getting routes: #{inspect(error)}") - %{"origin" => origin, "destination" => destination, "systems" => [], "success" => false} - end - end - @decorate cacheable( cache: Cache, key: "group-info-#{group_id}", @@ -273,6 +245,8 @@ defmodule WandererApp.Esi.ApiClient do opts: [ttl: @ttl] ) defp get_search(character_eve_id, search_val, categories_val, merged_opts) do + # Note: search_val and categories_val are used by the @decorate cacheable annotation above + _unused = {search_val, categories_val} get_character_auth_data(character_eve_id, "search", merged_opts) end @@ -348,7 +322,7 @@ defmodule WandererApp.Esi.ApiClient do defp with_cache_opts(opts), do: opts |> Keyword.merge(@cache_opts) |> Keyword.merge(cache_dir: System.tmp_dir!()) - defp do_get(path, api_opts \\ [], opts \\ [], pool \\ @general_pool) do + defp do_get(path, api_opts, opts, pool \\ @general_pool) do case Cachex.get(:api_cache, path) do {:ok, cached_data} when not is_nil(cached_data) -> {:ok, cached_data} @@ -358,7 +332,7 @@ defmodule WandererApp.Esi.ApiClient do end end - defp do_get_request(path, api_opts \\ [], opts \\ [], pool \\ @general_pool) do + defp do_get_request(path, api_opts, opts, pool) do try do req_options_for_pool(pool) |> Req.new() @@ -448,7 +422,7 @@ defmodule WandererApp.Esi.ApiClient do {:ok, %{status: status} = _error} when status in [401, 403] -> do_get_retry(path, api_opts, opts) - {:ok, %{status: status, headers: headers}} -> + {:ok, %{status: status}} -> {:error, "Unexpected status: #{status}"} {:error, %Mint.TransportError{reason: :timeout}} -> @@ -832,10 +806,10 @@ defmodule WandererApp.Esi.ApiClient do defp handle_refresh_token_result( {:error, %OAuth2.Error{reason: :econnrefused} = error}, - character, + _character, character_id, expires_at, - scopes + _scopes ) do expires_at_datetime = DateTime.from_unix!(expires_at) time_since_expiry = DateTime.diff(DateTime.utc_now(), expires_at_datetime, :second) diff --git a/lib/wanderer_app/eve_data_service.ex b/lib/wanderer_app/eve_data_service.ex index 8233bdbd..f0243771 100644 --- a/lib/wanderer_app/eve_data_service.ex +++ b/lib/wanderer_app/eve_data_service.ex @@ -393,9 +393,6 @@ defmodule WandererApp.EveDataService do end end - defp get_solar_system_name(solar_system_name, wormhole_class) do - end - defp get_triglavian_data(default_data, triglavian_systems, solar_system_id) do case Enum.find(triglavian_systems, fn system -> system.solar_system_id == solar_system_id end) do nil -> @@ -414,7 +411,7 @@ defmodule WandererApp.EveDataService do defp get_security(security) do case security do nil -> {:ok, ""} - _ -> {:ok, String.to_float(security) |> get_true_security() |> Float.to_string(decimals: 1)} + _ -> {:ok, String.to_float(security) |> get_true_security() |> :erlang.float_to_binary(decimals: 1)} end end @@ -496,23 +493,23 @@ defmodule WandererApp.EveDataService do do: {:ok, 10_100} defp get_wormhole_class_id(systems, region_id, constellation_id, solar_system_id) do - with region <- - Enum.find(systems, fn system -> - system.location_id |> Integer.parse() |> elem(0) == region_id - end), - constellation <- - Enum.find(systems, fn system -> - system.location_id |> Integer.parse() |> elem(0) == constellation_id - end), - solar_system <- - Enum.find(systems, fn system -> - system.location_id |> Integer.parse() |> elem(0) == solar_system_id - end), - wormhole_class_id <- get_wormhole_class_id(region, constellation, solar_system) do - {:ok, wormhole_class_id} - else - _ -> {:ok, -1} - end + region = + Enum.find(systems, fn system -> + system.location_id |> Integer.parse() |> elem(0) == region_id + end) + + constellation = + Enum.find(systems, fn system -> + system.location_id |> Integer.parse() |> elem(0) == constellation_id + end) + + solar_system = + Enum.find(systems, fn system -> + system.location_id |> Integer.parse() |> elem(0) == solar_system_id + end) + + wormhole_class_id = get_wormhole_class_id(region, constellation, solar_system) + {:ok, wormhole_class_id} end defp get_wormhole_class_id(_region, _constellation, solar_system) diff --git a/lib/wanderer_app/external_events/event.ex b/lib/wanderer_app/external_events/event.ex index e3b4a5c8..27539b71 100644 --- a/lib/wanderer_app/external_events/event.ex +++ b/lib/wanderer_app/external_events/event.ex @@ -178,6 +178,10 @@ defmodule WandererApp.ExternalEvents.Event do end end + defp serialize_payload(payload, visited) when is_map(payload) do + Map.new(payload, fn {k, v} -> {to_string(k), serialize_value(v, visited)} end) + end + # Get allowed fields based on struct type defp get_allowed_fields(module) do module_name = module |> Module.split() |> List.last() @@ -192,10 +196,6 @@ defmodule WandererApp.ExternalEvents.Event do end end - defp serialize_payload(payload, visited) when is_map(payload) do - Map.new(payload, fn {k, v} -> {to_string(k), serialize_value(v, visited)} end) - end - defp serialize_fields(fields, visited) do Enum.reduce(fields, %{}, fn {k, v}, acc -> if is_nil(v) do diff --git a/lib/wanderer_app/kills/client.ex b/lib/wanderer_app/kills/client.ex index 8471fe45..8ec49fbe 100644 --- a/lib/wanderer_app/kills/client.ex +++ b/lib/wanderer_app/kills/client.ex @@ -182,7 +182,7 @@ defmodule WandererApp.Kills.Client do end # Guard against duplicate disconnection events - def handle_info({:disconnected, reason}, %{connected: false, connecting: false} = state) do + def handle_info({:disconnected, _reason}, %{connected: false, connecting: false} = state) do {:noreply, state} end @@ -566,7 +566,7 @@ defmodule WandererApp.Kills.Client do end end - defp check_health(%{socket_pid: pid} = state) do + defp check_health(%{socket_pid: pid}) do if socket_alive?(pid) do :healthy else @@ -590,22 +590,6 @@ defmodule WandererApp.Kills.Client do Process.send_after(self(), :health_check, @health_check_interval) end - defp handle_connection_lost(%{connected: false} = _state) do - Logger.debug("[Client] Connection already lost, skipping cleanup") - end - - defp handle_connection_lost(state) do - Logger.warning("[Client] Connection lost, cleaning up and reconnecting") - - # Clean up existing socket - if state.socket_pid do - disconnect_socket(state.socket_pid) - end - - # Reset state and trigger reconnection - send(self(), {:disconnected, :connection_lost}) - end - # Handler module for WebSocket events defmodule Handler do @moduledoc """ @@ -640,7 +624,7 @@ defmodule WandererApp.Kills.Client do } case GenSocketClient.join(transport, "killmails:lobby", join_params) do - {:ok, response} -> + {:ok, _response} -> send(state.parent, {:connected, self()}) # Reset disconnected flag on successful connection {:ok, %{state | disconnected: false}} diff --git a/lib/wanderer_app/kills/map_event_listener.ex b/lib/wanderer_app/kills/map_event_listener.ex index aaed9223..9249b22f 100644 --- a/lib/wanderer_app/kills/map_event_listener.ex +++ b/lib/wanderer_app/kills/map_event_listener.ex @@ -46,7 +46,7 @@ defmodule WandererApp.Kills.MapEventListener do end @impl true - def handle_info(%{event: :map_server_started, payload: map_info}, state) do + def handle_info(%{event: :map_server_started, payload: _map_info}, state) do {:noreply, schedule_subscription_update(state)} end @@ -191,7 +191,7 @@ defmodule WandererApp.Kills.MapEventListener do # Client is not connected, retry with backoff schedule_retry_update(state) - error -> + _error -> schedule_retry_update(state) end rescue diff --git a/lib/wanderer_app/map.ex b/lib/wanderer_app/map.ex index e123a5f9..fb84fa68 100644 --- a/lib/wanderer_app/map.ex +++ b/lib/wanderer_app/map.ex @@ -177,7 +177,7 @@ defmodule WandererApp.Map do end def list_hubs(map_id, hubs) do - {:ok, map} = map_id |> get_map() + {:ok, _map} = map_id |> get_map() {:ok, hubs} end @@ -315,7 +315,7 @@ defmodule WandererApp.Map do end end - def update_subscription_settings!(%{map_id: map_id} = map, %{ + def update_subscription_settings!(%{map_id: map_id} = _map, %{ characters_limit: characters_limit, hubs_limit: hubs_limit }) do @@ -326,7 +326,7 @@ defmodule WandererApp.Map do |> get_map!() end - def update_options!(%{map_id: map_id} = map, options) do + def update_options!(%{map_id: map_id} = _map, options) do map_id |> update_map(%{options: options}) diff --git a/lib/wanderer_app/map/map_operations.ex b/lib/wanderer_app/map/map_operations.ex index 6dbe0dea..9297e5c8 100644 --- a/lib/wanderer_app/map/map_operations.ex +++ b/lib/wanderer_app/map/map_operations.ex @@ -76,11 +76,6 @@ defmodule WandererApp.Map.Operations do {:ok, map()} | {:skip, :exists} | {:error, String.t()} defdelegate create_connection(map_id, attrs, char_id), to: Connections - @doc "Create a connection from a Plug.Conn" - @spec create_connection(Plug.Conn.t(), map()) :: - {:ok, :created} | {:skip, :exists} | {:error, atom()} - defdelegate create_connection(conn, attrs), to: Connections - @doc "Update a connection" @spec update_connection(String.t(), String.t(), map()) :: {:ok, map()} | {:error, String.t()} diff --git a/lib/wanderer_app/map/map_pool.ex b/lib/wanderer_app/map/map_pool.ex index b174b70d..e6e679d1 100644 --- a/lib/wanderer_app/map/map_pool.ex +++ b/lib/wanderer_app/map/map_pool.ex @@ -329,6 +329,9 @@ defmodule WandererApp.Map.MapPool do end end + @impl true + def handle_call(:error, _, state), do: {:stop, :error, :ok, state} + defp do_start_map(map_id, %{map_ids: map_ids, uuid: uuid} = state) do if map_id in map_ids do # Map already started @@ -344,8 +347,6 @@ defmodule WandererApp.Map.MapPool do [map_id | r_map_ids] end) - completed_operations = [:registry | completed_operations] - case registry_result do {new_value, _old_value} when is_list(new_value) -> :ok @@ -363,13 +364,9 @@ defmodule WandererApp.Map.MapPool do raise "Failed to add to cache: #{inspect(reason)}" end - completed_operations = [:cache | completed_operations] - # Step 3: Start the map server using extracted helper do_initialize_map_server(map_id) - completed_operations = [:map_server | completed_operations] - # Step 4: Update GenServer state (last, as this is in-memory and fast) new_state = %{state | map_ids: [map_id | map_ids]} @@ -445,8 +442,6 @@ defmodule WandererApp.Map.MapPool do r_map_ids |> Enum.reject(fn id -> id == map_id end) end) - completed_operations = [:registry | completed_operations] - case registry_result do {new_value, _old_value} when is_list(new_value) -> :ok @@ -464,14 +459,10 @@ defmodule WandererApp.Map.MapPool do raise "Failed to delete from cache: #{inspect(reason)}" end - completed_operations = [:cache | completed_operations] - # Step 3: Stop the map server (clean up all map resources) map_id |> Server.Impl.stop_map() - completed_operations = [:map_server | completed_operations] - # Step 4: Update GenServer state (last, as this is in-memory and fast) new_state = %{state | map_ids: map_ids |> Enum.reject(fn id -> id == map_id end)} @@ -560,9 +551,6 @@ defmodule WandererApp.Map.MapPool do # and the cleanup operations are safe to leave in a "stopped" state end - @impl true - def handle_call(:error, _, state), do: {:stop, :error, :ok, state} - @impl true def handle_info(:backup_state, %{map_ids: map_ids, uuid: uuid} = state) do Process.send_after(self(), :backup_state, @backup_state_timeout) diff --git a/lib/wanderer_app/map/map_pool_dynamic_supervisor.ex b/lib/wanderer_app/map/map_pool_dynamic_supervisor.ex index d17ba57d..76d61e14 100644 --- a/lib/wanderer_app/map/map_pool_dynamic_supervisor.ex +++ b/lib/wanderer_app/map/map_pool_dynamic_supervisor.ex @@ -180,14 +180,4 @@ defmodule WandererApp.Map.MapPoolDynamicSupervisor do end end - defp stop_child(uuid) do - case Registry.lookup(@registry, uuid) do - [{pid, _}] -> - GenServer.cast(pid, :stop) - - _ -> - Logger.warn("Unable to locate pool assigned to #{inspect(uuid)}") - :ok - end - end end diff --git a/lib/wanderer_app/map/map_routes.ex b/lib/wanderer_app/map/map_routes.ex index e3438177..258b075a 100644 --- a/lib/wanderer_app/map/map_routes.ex +++ b/lib/wanderer_app/map/map_routes.ex @@ -77,7 +77,7 @@ defmodule WandererApp.Map.Routes do end end - def find(_map_id, hubs, origin, routes_settings, true) do + def find(_map_id, hubs, origin, _routes_settings, true) do origin = origin |> String.to_integer() hubs = hubs |> Enum.map(&(&1 |> String.to_integer())) diff --git a/lib/wanderer_app/map/operations/connections.ex b/lib/wanderer_app/map/operations/connections.ex index 6dd72c42..72d54651 100644 --- a/lib/wanderer_app/map/operations/connections.ex +++ b/lib/wanderer_app/map/operations/connections.ex @@ -93,10 +93,8 @@ defmodule WandererApp.Map.Operations.Connections do end end - @doc """ - Determines the ship size for a connection, applying wormhole‑specific rules - for C1, C13, and C4⇄NS links, falling back to the caller’s provided size or Large. - """ + # Determines the ship size for a connection, applying wormhole-specific rules + # for C1, C13, and C4⇄NS links, falling back to the caller's provided size or Large. defp resolve_ship_size(type_val, ship_size_val, src_info, tgt_info) do case parse_type(type_val) do @connection_type_wormhole -> diff --git a/lib/wanderer_app/map/operations/duplication.ex b/lib/wanderer_app/map/operations/duplication.ex index 4ab422e7..308f0f2c 100644 --- a/lib/wanderer_app/map/operations/duplication.ex +++ b/lib/wanderer_app/map/operations/duplication.ex @@ -12,7 +12,6 @@ defmodule WandererApp.Map.Operations.Duplication do """ require Logger - import Ash.Query, only: [filter: 2] alias WandererApp.Api alias WandererApp.Api.{MapSystem, MapConnection, MapSystemSignature, MapCharacterSettings} diff --git a/lib/wanderer_app/map/server/map_server_connections_impl.ex b/lib/wanderer_app/map/server/map_server_connections_impl.ex index ce788f21..21b89035 100644 --- a/lib/wanderer_app/map/server/map_server_connections_impl.ex +++ b/lib/wanderer_app/map/server/map_server_connections_impl.ex @@ -100,7 +100,7 @@ defmodule WandererApp.Map.Server.ConnectionsImpl do @connection_type_wormhole 0 @connection_type_stargate 1 - @connection_type_bridge 2 + # @connection_type_bridge 2 # reserved for future use @medium_ship_size 1 def get_connection_auto_expire_hours(), do: WandererApp.Env.map_connection_auto_expire_hours() @@ -403,7 +403,7 @@ defmodule WandererApp.Map.Server.ConnectionsImpl do time_status: time_status, solar_system_source: solar_system_source, solar_system_target: solar_system_target - } = updated_connection + } = _updated_connection ) do with source_system when not is_nil(source_system) <- WandererApp.Map.find_system_by_location( @@ -909,9 +909,6 @@ defmodule WandererApp.Map.Server.ConnectionsImpl do end end - defp get_time_status(_source_solar_system_id, _target_solar_system_id, _ship_size_type), - do: @connection_time_status_default - defp get_new_time_status(_start_time, @connection_time_status_default), do: @connection_time_status_eol_24 diff --git a/lib/wanderer_app/map/server/map_server_impl.ex b/lib/wanderer_app/map/server/map_server_impl.ex index 5f4dcf46..b7986fd0 100644 --- a/lib/wanderer_app/map/server/map_server_impl.ex +++ b/lib/wanderer_app/map/server/map_server_impl.ex @@ -156,7 +156,7 @@ defmodule WandererApp.Map.Server.Impl do Logger.error("Cannot start map #{map_id}: map not loaded") {:error, :map_not_loaded} - map -> + _map -> with :ok <- AclsImpl.track_acls(acls |> Enum.map(& &1.access_list_id)) do @pubsub_client.subscribe( WandererApp.PubSub, diff --git a/lib/wanderer_app/map/server/map_server_pings_impl.ex b/lib/wanderer_app/map/server/map_server_pings_impl.ex index 9b8e796b..b96e8b37 100644 --- a/lib/wanderer_app/map/server/map_server_pings_impl.ex +++ b/lib/wanderer_app/map/server/map_server_pings_impl.ex @@ -5,7 +5,7 @@ defmodule WandererApp.Map.Server.PingsImpl do alias WandererApp.Map.Server.Impl - @ping_auto_expire_timeout :timer.minutes(15) + # @ping_auto_expire_timeout :timer.minutes(15) # reserved for future use def add_ping( map_id, diff --git a/lib/wanderer_app/map/server/map_server_systems_impl.ex b/lib/wanderer_app/map/server/map_server_systems_impl.ex index f9cb9342..0c9f71f1 100644 --- a/lib/wanderer_app/map/server/map_server_systems_impl.ex +++ b/lib/wanderer_app/map/server/map_server_systems_impl.ex @@ -129,8 +129,8 @@ defmodule WandererApp.Map.Server.SystemsImpl do def remove_system_comment( map_id, comment_id, - user_id, - character_id + _user_id, + _character_id ) do {:ok, %{system_id: system_id} = comment} = WandererApp.MapSystemCommentRepo.get_by_id(comment_id) @@ -309,7 +309,7 @@ defmodule WandererApp.Map.Server.SystemsImpl do map_id |> WandererApp.MapSystemRepo.remove_from_map(solar_system_id) |> case do - {:ok, result} -> + {:ok, _result} -> :ok = WandererApp.Map.remove_system(map_id, solar_system_id) @ddrt.delete([solar_system_id], "rtree_#{map_id}") Impl.broadcast!(map_id, :systems_removed, [solar_system_id]) @@ -863,10 +863,8 @@ defmodule WandererApp.Map.Server.SystemsImpl do updated_system end - defp maybe_update_labels(system, _labels), do: system - defp maybe_update_labels( - %{name: old_labels} = system, + %{labels: old_labels} = system, labels ) when not is_nil(labels) and old_labels != labels do diff --git a/lib/wanderer_app/maps.ex b/lib/wanderer_app/maps.ex index dac21e2c..7c04a996 100644 --- a/lib/wanderer_app/maps.ex +++ b/lib/wanderer_app/maps.ex @@ -128,7 +128,7 @@ defmodule WandererApp.Maps do tracked: tracked } - defp get_map_characters(%{id: map_id} = map) do + defp get_map_characters(%{id: map_id} = _map) do WandererApp.Cache.lookup!("map_characters-#{map_id}") |> case do nil -> diff --git a/lib/wanderer_app/repositories/map_connection_repo.ex b/lib/wanderer_app/repositories/map_connection_repo.ex index d7628e56..124080df 100644 --- a/lib/wanderer_app/repositories/map_connection_repo.ex +++ b/lib/wanderer_app/repositories/map_connection_repo.ex @@ -99,7 +99,7 @@ defmodule WandererApp.MapConnectionRepo do def get_by_id(map_id, id) do # Use read_by_map action which doesn't have the FilterConnectionsByActorMap preparation # that was causing "filter being false" errors in tests - import Ash.Query + require Ash.Query WandererApp.Api.MapConnection |> Ash.Query.for_read(:read_by_map, %{map_id: map_id}) diff --git a/lib/wanderer_app/repositories/map_pings_repo.ex b/lib/wanderer_app/repositories/map_pings_repo.ex index 47a6af93..bab3d4bb 100644 --- a/lib/wanderer_app/repositories/map_pings_repo.ex +++ b/lib/wanderer_app/repositories/map_pings_repo.ex @@ -38,6 +38,4 @@ defmodule WandererApp.MapPingsRepo do :ok end - - def destroy(_ping_id), do: :ok end diff --git a/lib/wanderer_app/repositories/map_repo.ex b/lib/wanderer_app/repositories/map_repo.ex index 1c945023..9a06da84 100644 --- a/lib/wanderer_app/repositories/map_repo.ex +++ b/lib/wanderer_app/repositories/map_repo.ex @@ -84,7 +84,7 @@ defmodule WandererApp.MapRepo do end end - error in Ash.Error.Query.NotFound -> + _error in Ash.Error.Query.NotFound -> Logger.debug("Map not found with slug: #{slug}") {:error, :not_found} diff --git a/lib/wanderer_app/security_audit.ex b/lib/wanderer_app/security_audit.ex index 1af462f5..7c5f380a 100644 --- a/lib/wanderer_app/security_audit.ex +++ b/lib/wanderer_app/security_audit.ex @@ -487,15 +487,6 @@ defmodule WandererApp.SecurityAudit do # Private functions - defp store_audit_entry(_audit_entry) do - # Handle async processing if enabled - # if async_enabled?() do - # WandererApp.SecurityAudit.AsyncProcessor.log_event(audit_entry) - # else - # do_store_audit_entry(audit_entry) - # end - end - @doc false def do_store_audit_entry(audit_entry) do # Ensure event_type is properly formatted @@ -631,11 +622,6 @@ defmodule WandererApp.SecurityAudit do end end - defp async_enabled? do - Application.get_env(:wanderer_app, __MODULE__, []) - |> Keyword.get(:async, false) - end - defp emit_telemetry_event(audit_entry) do :telemetry.execute( [:wanderer_app, :security_audit], diff --git a/lib/wanderer_app/test/logger.ex b/lib/wanderer_app/test/logger.ex index 17bb3fd1..ecdefd96 100644 --- a/lib/wanderer_app/test/logger.ex +++ b/lib/wanderer_app/test/logger.ex @@ -5,7 +5,11 @@ defmodule WandererApp.Test.Logger do """ @callback info(message :: iodata() | (-> iodata())) :: :ok + @callback info(message :: iodata() | (-> iodata()), metadata :: keyword()) :: :ok @callback error(message :: iodata() | (-> iodata())) :: :ok + @callback error(message :: iodata() | (-> iodata()), metadata :: keyword()) :: :ok @callback warning(message :: iodata() | (-> iodata())) :: :ok + @callback warning(message :: iodata() | (-> iodata()), metadata :: keyword()) :: :ok @callback debug(message :: iodata() | (-> iodata())) :: :ok + @callback debug(message :: iodata() | (-> iodata()), metadata :: keyword()) :: :ok end diff --git a/lib/wanderer_app/test/logger_stub.ex b/lib/wanderer_app/test/logger_stub.ex index 819e4858..49886053 100644 --- a/lib/wanderer_app/test/logger_stub.ex +++ b/lib/wanderer_app/test/logger_stub.ex @@ -9,12 +9,24 @@ defmodule WandererApp.Test.LoggerStub do @impl true def info(_message), do: :ok + @impl true + def info(_message, _metadata), do: :ok + @impl true def error(_message), do: :ok + @impl true + def error(_message, _metadata), do: :ok + @impl true def warning(_message), do: :ok + @impl true + def warning(_message, _metadata), do: :ok + @impl true def debug(_message), do: :ok + + @impl true + def debug(_message, _metadata), do: :ok end diff --git a/lib/wanderer_app/vault.ex b/lib/wanderer_app/vault.ex index 6e8c49a0..3fac1be6 100644 --- a/lib/wanderer_app/vault.ex +++ b/lib/wanderer_app/vault.ex @@ -124,7 +124,7 @@ defmodule WandererApp.Vault do end) end - defp find_fallback_module_to_decrypt(config, ciphertext) do + defp find_fallback_module_to_decrypt(config, _ciphertext) do Enum.find(config[:ciphers], fn {label, _} -> label == :fallback end) diff --git a/lib/wanderer_app_web/api_router.ex b/lib/wanderer_app_web/api_router.ex index bc80f428..edb0b00e 100644 --- a/lib/wanderer_app_web/api_router.ex +++ b/lib/wanderer_app_web/api_router.ex @@ -12,7 +12,6 @@ defmodule WandererAppWeb.ApiRouter do """ use Phoenix.Router - import WandererAppWeb.ApiRouterHelpers alias WandererAppWeb.{ApiRoutes, ApiRouter.RouteSpec} require Logger @@ -171,7 +170,7 @@ defmodule WandererAppWeb.ApiRouter do |> halt() end - defp find_similar_routes(path_info, version) do + defp find_similar_routes(path_info, _version) do # Find routes with similar paths in current or other versions all_routes = ApiRoutes.table() diff --git a/lib/wanderer_app_web/api_spec.ex b/lib/wanderer_app_web/api_spec.ex index dfb08db8..9c39984f 100644 --- a/lib/wanderer_app_web/api_spec.ex +++ b/lib/wanderer_app_web/api_spec.ex @@ -1,7 +1,7 @@ defmodule WandererAppWeb.ApiSpec do @behaviour OpenApiSpex.OpenApi - alias OpenApiSpex.{OpenApi, Info, Paths, Components, SecurityScheme, Server, Schema} + alias OpenApiSpex.{OpenApi, Info, Paths, Components, SecurityScheme, Server} alias WandererAppWeb.{Endpoint, Router} alias WandererAppWeb.Schemas.ApiSchemas diff --git a/lib/wanderer_app_web/components/core_components.ex b/lib/wanderer_app_web/components/core_components.ex index 19ae39d8..29c45c20 100644 --- a/lib/wanderer_app_web/components/core_components.ex +++ b/lib/wanderer_app_web/components/core_components.ex @@ -284,6 +284,7 @@ defmodule WandererAppWeb.CoreComponents do """ attr(:type, :string, default: nil) attr(:class, :string, default: nil) + attr(:data, :any, default: nil) attr(:rest, :global, include: ~w(disabled form name value)) slot(:inner_block, required: true) @@ -296,6 +297,7 @@ defmodule WandererAppWeb.CoreComponents do "phx-submit-loading:opacity-75 p-button p-component p-button-outlined p-button-sm", @class ]} + data={@data} {@rest} > {render_slot(@inner_block)} @@ -614,7 +616,7 @@ defmodule WandererAppWeb.CoreComponents do attr(:empty_label, :string, default: nil) attr(:rows, :list, required: true) attr(:row_id, :any, default: nil, doc: "the function for generating the row id") - attr(:row_selected, :boolean, default: false, doc: "the function for generating the row id") + attr(:row_selected, :any, default: false, doc: "the function for generating the row id") attr(:row_click, :any, default: nil, doc: "the function for handling phx-click on each row") attr(:row_item, :any, @@ -703,13 +705,21 @@ defmodule WandererAppWeb.CoreComponents do """ end + attr(:field, :any, required: true) attr(:placeholder, :string, default: nil) attr(:label, :string, default: nil) attr(:label_class, :string, default: nil) attr(:input_class, :string, default: nil) attr(:dropdown_extra_class, :string, default: nil) attr(:option_extra_class, :string, default: nil) + attr(:mode, :atom, default: nil) + attr(:options, :list, default: []) + attr(:debounce, :integer, default: nil) + attr(:update_min_len, :integer, default: nil) + attr(:available_option_class, :string, default: nil) + attr(:value_mapper, :any, default: nil) slot(:inner_block) + slot(:option) def live_select(%{field: %Phoenix.HTML.FormField{} = field} = assigns) do assigns = diff --git a/lib/wanderer_app_web/controllers/license_api_controller.ex b/lib/wanderer_app_web/controllers/license_api_controller.ex index 45dda006..b2175533 100644 --- a/lib/wanderer_app_web/controllers/license_api_controller.ex +++ b/lib/wanderer_app_web/controllers/license_api_controller.ex @@ -123,11 +123,6 @@ defmodule WandererAppWeb.LicenseApiController do end end - def update_validity(conn, %{"id" => _license_id}) do - conn - |> put_status(:bad_request) - |> json(%{error: "Missing required parameter: is_valid"}) - end @doc """ Updates a license's expiration date. diff --git a/lib/wanderer_app_web/controllers/map_api_controller.ex b/lib/wanderer_app_web/controllers/map_api_controller.ex index 923307af..5437dda4 100644 --- a/lib/wanderer_app_web/controllers/map_api_controller.ex +++ b/lib/wanderer_app_web/controllers/map_api_controller.ex @@ -2,12 +2,10 @@ defmodule WandererAppWeb.MapAPIController do use WandererAppWeb, :controller use OpenApiSpex.ControllerSpecs - import Ash.Query, only: [filter: 2] + require Ash.Query require Logger - alias WandererApp.Api.Character alias WandererApp.MapSystemRepo - alias WandererApp.MapCharacterSettingsRepo alias WandererApp.MapConnectionRepo alias WandererAppWeb.Helpers.APIUtils alias WandererAppWeb.Schemas.{ApiSchemas, ResponseSchemas} @@ -16,7 +14,7 @@ defmodule WandererAppWeb.MapAPIController do # V1 API Actions (for compatibility with versioned API router) # ----------------------------------------------------------------- - def index_v1(conn, params) do + def index_v1(conn, _params) do # Delegate to the existing list implementation or create a basic one json(conn, %{ data: [], @@ -43,7 +41,7 @@ defmodule WandererAppWeb.MapAPIController do }) end - def create_v1(conn, params) do + def create_v1(conn, _params) do # Basic create implementation for testing json(conn, %{ data: %{ @@ -59,7 +57,7 @@ defmodule WandererAppWeb.MapAPIController do }) end - def update_v1(conn, %{"id" => id} = params) do + def update_v1(conn, %{"id" => id} = _params) do # Basic update implementation for testing json(conn, %{ data: %{ @@ -82,7 +80,7 @@ defmodule WandererAppWeb.MapAPIController do |> text("") end - def duplicate_v1(conn, %{"id" => id} = params) do + def duplicate_v1(conn, %{"id" => id} = _params) do # Basic duplicate implementation for testing json(conn, %{ data: %{ @@ -99,7 +97,7 @@ defmodule WandererAppWeb.MapAPIController do }) end - def bulk_create_v1(conn, params) do + def bulk_create_v1(conn, _params) do # Basic bulk create implementation for testing json(conn, %{ data: [ @@ -121,7 +119,7 @@ defmodule WandererAppWeb.MapAPIController do }) end - def bulk_update_v1(conn, params) do + def bulk_update_v1(conn, _params) do # Basic bulk update implementation for testing json(conn, %{ data: [ @@ -325,13 +323,6 @@ defmodule WandererAppWeb.MapAPIController do # Helper functions for the API controller # ----------------------------------------------------------------- - defp get_map_id_by_slug(slug) do - case WandererApp.Api.Map.get_map_by_slug(slug) do - {:ok, map} -> {:ok, map.id} - {:error, error} -> {:error, "Map not found for slug: #{slug}, error: #{inspect(error)}"} - end - end - defp normalize_map_identifier(params) do case Map.get(params, "map_identifier") do nil -> diff --git a/lib/wanderer_app_web/controllers/map_audit_api_controller.ex b/lib/wanderer_app_web/controllers/map_audit_api_controller.ex index a384ecfb..51bd963b 100644 --- a/lib/wanderer_app_web/controllers/map_audit_api_controller.ex +++ b/lib/wanderer_app_web/controllers/map_audit_api_controller.ex @@ -4,8 +4,6 @@ defmodule WandererAppWeb.MapAuditAPIController do require Logger - alias WandererApp.Api - alias WandererAppWeb.Helpers.APIUtils # ----------------------------------------------------------------- diff --git a/lib/wanderer_app_web/controllers/map_events_api_controller.ex b/lib/wanderer_app_web/controllers/map_events_api_controller.ex index 4ae8ab20..47d525cd 100644 --- a/lib/wanderer_app_web/controllers/map_events_api_controller.ex +++ b/lib/wanderer_app_web/controllers/map_events_api_controller.ex @@ -65,24 +65,6 @@ defmodule WandererAppWeb.MapEventsAPIController do items: @event_schema }) - @events_list_params %OpenApiSpex.Schema{ - type: :object, - properties: %{ - since: %OpenApiSpex.Schema{ - type: :string, - format: :date_time, - description: "Return events after this timestamp (ISO8601)" - }, - limit: %OpenApiSpex.Schema{ - type: :integer, - minimum: 1, - maximum: 100, - default: 100, - description: "Maximum number of events to return" - } - } - } - # ----------------------------------------------------------------- # OpenApiSpex Operations # ----------------------------------------------------------------- @@ -173,7 +155,7 @@ defmodule WandererAppWeb.MapEventsAPIController do |> put_status(:bad_request) |> json(%{error: "Invalid 'limit' parameter. Must be between 1 and 100."}) - {:error, reason} -> + {:error, _reason} -> conn |> put_status(:internal_server_error) |> json(%{error: "Internal server error"}) @@ -184,7 +166,7 @@ defmodule WandererAppWeb.MapEventsAPIController do # Private Functions # ----------------------------------------------------------------- - defp get_map(conn, map_identifier) do + defp get_map(conn, _map_identifier) do # The map should already be loaded by the CheckMapApiKey plug case conn.assigns[:map] do nil -> {:error, :map_not_found} diff --git a/lib/wanderer_app_web/controllers/plugs/json_api_performance_monitor.ex b/lib/wanderer_app_web/controllers/plugs/json_api_performance_monitor.ex index 4443141e..0e8b54f2 100644 --- a/lib/wanderer_app_web/controllers/plugs/json_api_performance_monitor.ex +++ b/lib/wanderer_app_web/controllers/plugs/json_api_performance_monitor.ex @@ -36,7 +36,7 @@ defmodule WandererAppWeb.Plugs.JsonApiPerformanceMonitor do conn |> register_before_send(fn conn -> end_time = System.monotonic_time(:millisecond) - duration = end_time - start_time + _duration = end_time - start_time # Extract response metadata response_metadata = extract_response_metadata(conn, request_metadata) diff --git a/lib/wanderer_app_web/controllers/plugs/license_auth.ex b/lib/wanderer_app_web/controllers/plugs/license_auth.ex index eb126498..8f36fc62 100644 --- a/lib/wanderer_app_web/controllers/plugs/license_auth.ex +++ b/lib/wanderer_app_web/controllers/plugs/license_auth.ex @@ -12,7 +12,6 @@ defmodule WandererAppWeb.Plugs.LicenseAuth do require Logger alias WandererApp.License.LicenseManager - alias WandererApp.Helpers.Config @doc """ Authenticates requests using the LM_AUTH_KEY. @@ -21,7 +20,7 @@ defmodule WandererAppWeb.Plugs.LicenseAuth do """ def authenticate_lm(conn, _opts) do auth_header = get_req_header(conn, "authorization") - lm_auth_key = Config.get_env(:wanderer_app, :lm_auth_key) + lm_auth_key = Application.get_env(:wanderer_app, :lm_auth_key) case auth_header do ["Bearer " <> token] -> diff --git a/lib/wanderer_app_web/controllers/user_auth.ex b/lib/wanderer_app_web/controllers/user_auth.ex index af768c9c..1fcf4ea3 100755 --- a/lib/wanderer_app_web/controllers/user_auth.ex +++ b/lib/wanderer_app_web/controllers/user_auth.ex @@ -37,7 +37,7 @@ defmodule WandererAppWeb.UserAuth do nil -> {:halt, redirect_require_login(socket)} - %User{characters: characters} -> + %User{characters: _characters} -> {:cont, new_socket} end @@ -112,13 +112,6 @@ defmodule WandererAppWeb.UserAuth do |> LiveView.redirect(to: ~p"/") end - defp track_characters([]), do: :ok - - defp track_characters([%{id: character_id} | characters]) do - :ok = WandererApp.Character.TrackerManager.start_tracking(character_id) - track_characters(characters) - end - defp maybe_store_return_to(%{method: "GET"} = conn) do %{request_path: request_path, query_string: query_string} = conn return_to = if query_string == "", do: request_path, else: request_path <> "?" <> query_string diff --git a/lib/wanderer_app_web/live/access_lists/access_lists_live.ex b/lib/wanderer_app_web/live/access_lists/access_lists_live.ex index 8fa76a2d..3d07c1ba 100755 --- a/lib/wanderer_app_web/live/access_lists/access_lists_live.ex +++ b/lib/wanderer_app_web/live/access_lists/access_lists_live.ex @@ -688,7 +688,7 @@ defmodule WandererAppWeb.AccessListsLive do """ end - slot(:option) + attr(:option, :any, required: true) def search_member_item(assigns) do ~H""" diff --git a/lib/wanderer_app_web/live/access_lists/access_lists_live.html.heex b/lib/wanderer_app_web/live/access_lists/access_lists_live.html.heex index fe736092..e3c46682 100644 --- a/lib/wanderer_app_web/live/access_lists/access_lists_live.html.heex +++ b/lib/wanderer_app_web/live/access_lists/access_lists_live.html.heex @@ -115,13 +115,20 @@ <.link - disabled={@selected_acl_id == "" or not can_add_members?(@access_list, @current_user)} + :if={@selected_acl_id != "" and can_add_members?(@access_list, @current_user)} class="btn mt-2 w-full btn-neutral rounded-none" patch={~p"/access-lists/#{@selected_acl_id}/add-members"} > <.icon name="hero-plus-solid" class="w-6 h-6" />