Credo: Map.new over Enum.map into a map

10e4d95 · Gabe Morell · 2026-11-04 21:21

33 files +36 -46

Files changed

modified apps/room_gtfs/lib/room_gtfs/gtfs_worker.ex
+1 −2
@@ -742,12 +742,11 @@ defmodule RoomGtfs.Worker do
742 742 on_timeout: :kill_task
743 743 )
744 744 |> Enum.zip(@stat_names)
745 − |> Enum.map(fn
745 + |> Map.new(fn
746 746 {{:ok, value}, name} -> {name, value}
747 747 # One count that will not answer should not cost the other ten.
748 748 {{:exit, _reason}, name} -> {name, :unavailable}
749 749 end)
750 − |> Enum.into(%{})
751 750 end
752 751
753 752 # In the source's own timezone: a board in Boston rolls over to the next
modified apps/room_sanctum/lib/room_sanctum/condensers/basic_mqtt.ex
+1 −2
@@ -286,13 +286,12 @@ defmodule RoomSanctum.Condenser.BasicMQTT do
286 286
287 287 defp condense_type(:ephem, data) do
288 288 data
289 − |> Enum.map(fn f ->
289 + |> Map.new(fn f ->
290 290 case Map.get(f, :period) do
291 291 nil -> {:name, f.name}
292 292 _val -> {f.period, f.result}
293 293 end
294 294 end)
295 − |> Enum.into(%{})
296 295 |> wrap
297 296 end
298 297
modified apps/room_sanctum/lib/room_sanctum/workers/keryx_worker.ex
+1 −2
@@ -293,8 +293,7 @@ defmodule RoomSanctum.Worker.Keryx do
293 293 discover(keryx, results)
294 294
295 295 results
296 − |> Enum.map(fn {key, r, _meta} -> {key, r} end)
297 − |> Enum.into(%{})
296 + |> Map.new(fn {key, r, _meta} -> {key, r} end)
298 297 end
299 298
300 299 # Home Assistant discovery for each query's `.meta`, through every Ankyra the
modified apps/room_sanctum/lib/room_sanctum/workers/pythiae_worker.ex
+3 −3
@@ -83,8 +83,8 @@ defmodule RoomSanctum.Worker.Pythiae do
83 83 comparison = DateTime.add(state.lastpub, cfg_ttl, :second)
84 84
85 85 if current != state.vision and DateTime.compare(DateTime.utc_now(), comparison) == :gt do
86 −# IO.puts("change detected")
87 −# IO.inspect({DateTime.utc_now(), comparison})
86 + # IO.puts("change detected")
87 + # IO.inspect({DateTime.utc_now(), comparison})
88 88
89 89 publish_board(state, current)
90 90
@@ -178,7 +178,7 @@ defmodule RoomSanctum.Worker.Pythiae do
178 178
179 179 defp condense(data, queries, reading \\ :basic) do
180 180 # Create a map of query id to query info for quick lookup
181 − query_map = queries |> Enum.map(fn q -> {q.id, q} end) |> Enum.into(%{})
181 + query_map = Map.new(queries, fn q -> {q.id, q} end)
182 182
183 183 data
184 184 |> Enum.map(fn {{id, type}, datum} ->
modified apps/room_sanctum/lib/room_sanctum_web/components/query_geospatial_map.ex
+1 −4
@@ -1087,10 +1087,7 @@ defmodule RoomSanctumWeb.Components.QueryGeospatialMap do
1087 1087 # Format stations for map display
1088 1088 defp format_stations(stations, station_statuses \\ [], source_tint \\ nil) do
1089 1089 # Create a map of station status by station_id for quick lookup
1090 − status_map =
1091 − Enum.reduce(station_statuses, %{}, fn status, acc ->
1092 − Map.put(acc, status.station_id, status)
1093 − end)
1090 + status_map = Map.new(station_statuses, &{&1.station_id, &1})
1094 1091
1095 1092 stations
1096 1093 |> Enum.filter(fn station ->
modified apps/room_sanctum/lib/room_sanctum_web/live/cfg_pythiae_live/form_component.ex
+3 −6

Click to load diff…

modified apps/room_sanctum/lib/room_sanctum_web/live/cfg_pythiae_live/public.ex
+2 −2

Click to load diff…

modified apps/room_sanctum/lib/room_sanctum_web/live/cfg_pythiae_live/show.ex
+2 −2

Click to load diff…

modified apps/room_sanctum/lib/room_sanctum_web/live/cfg_scribus_live/public.ex
+2 −2

Click to load diff…

modified apps/room_sanctum/lib/room_sanctum_web/live/cfg_source_live/import_component.ex
+15 −13

Click to load diff…

modified apps/room_sanctum/lib/room_sanctum_web/live/cfg_source_live/index.ex
+1 −2

Click to load diff…

modified apps/room_sanctum/lib/room_sanctum_web/live/cfg_vision_live/show.ex
+2 −2

Click to load diff…

modified apps/room_sanctum/lib/room_sanctum_web/live/landing_live/index.ex
+1 −2

Click to load diff…

modified apps/room_sanctum/test/room_sanctum/vision_query_batch_test.exs
+1 −2

Click to load diff…

Parents: 453b3df