Skip to content

Commit 9be4dbb

Browse files
committed
Fix all compiler warnings
1 parent f623eab commit 9be4dbb

4 files changed

Lines changed: 22 additions & 30 deletions

File tree

lib/beacon/content.ex

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4395,7 +4395,6 @@ defmodule Beacon.Content do
43954395
case insert_published_page(page) do
43964396
{:ok, page} ->
43974397
:ok = Beacon.PubSub.page_published(page)
4398-
# Async: extract internal links from the published page
43994398
maybe_rebuild_links_async(page)
44004399
{:reply, {:ok, page}, config}
44014400

@@ -4404,26 +4403,6 @@ defmodule Beacon.Content do
44044403
end
44054404
end
44064405

4407-
defp maybe_rebuild_links_async(page) do
4408-
Task.start(fn ->
4409-
try do
4410-
template = Beacon.Lifecycle.Template.load_template(page)
4411-
ast = Beacon.Template.Parser.parse(template)
4412-
component_registry = build_component_registry_for_ast(page.site)
4413-
expanded = Beacon.Template.ComponentExpander.expand(ast, component_registry)
4414-
# Render with empty assigns — works for static pages.
4415-
# Pages with data bindings will fail here, which is expected.
4416-
# Their links are extracted when the client reports them (future feature).
4417-
html = Beacon.Client.LiveViewCompiler.render_to_string(expanded, %{})
4418-
rebuild_links_for_page(page.site, page.id, html)
4419-
rescue
4420-
_error -> :ok
4421-
catch
4422-
_kind, _reason -> :ok
4423-
end
4424-
end)
4425-
end
4426-
44274406
@doc false
44284407
def handle_call({:unpublish_page, page}, _from, config) do
44294408
case insert_unpublished_page(page) do
@@ -4879,6 +4858,23 @@ defmodule Beacon.Content do
48794858
{:noreply, config}
48804859
end
48814860

4861+
defp maybe_rebuild_links_async(page) do
4862+
Task.start(fn ->
4863+
try do
4864+
template = Beacon.Lifecycle.Template.load_template(page)
4865+
ast = Beacon.Template.Parser.parse(template)
4866+
component_registry = build_component_registry_for_ast(page.site)
4867+
expanded = Beacon.Template.ComponentExpander.expand(ast, component_registry)
4868+
html = Beacon.Client.LiveViewCompiler.render_to_string(expanded, %{})
4869+
rebuild_links_for_page(page.site, page.id, html)
4870+
rescue
4871+
_error -> :ok
4872+
catch
4873+
_kind, _reason -> :ok
4874+
end
4875+
end)
4876+
end
4877+
48824878
# ---------------------------------------------------------------------------
48834879
# Template Types
48844880
# ---------------------------------------------------------------------------
@@ -4909,7 +4905,7 @@ defmodule Beacon.Content do
49094905
@doc "Lists template types available to a site (includes global types where site is nil)."
49104906
@doc type: :template_types
49114907
@spec list_template_types(Site.t(), keyword()) :: [TemplateType.t()]
4912-
def list_template_types(site, opts \\ []) when is_atom(site) do
4908+
def list_template_types(site, _opts \\ []) when is_atom(site) do
49134909
from(tt in TemplateType,
49144910
where: tt.site == ^site or is_nil(tt.site),
49154911
order_by: [asc: tt.name]

lib/beacon/content/content_diff.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ defmodule Beacon.Content.ContentDiff do
6767

6868
# Computes the percentage of tokens that differ using set-based comparison.
6969
defp token_change_percentage([], []), do: 0.0
70-
defp token_change_percentage(current, []), do: 1.0
71-
defp token_change_percentage([], previous), do: 1.0
70+
defp token_change_percentage(_current, []), do: 1.0
71+
defp token_change_percentage([], _previous), do: 1.0
7272

7373
defp token_change_percentage(current, previous) do
7474
current_set = MapSet.new(current)

lib/beacon/seo/index_now.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ defmodule Beacon.SEO.IndexNow do
153153
end
154154

155155
defp http_post(url, body) do
156-
headers = [{'content-type', 'application/json; charset=utf-8'}]
157-
:httpc.request(:post, {String.to_charlist(url), headers, 'application/json', String.to_charlist(body)}, [timeout: 10_000], [])
156+
headers = [{~c"content-type", ~c"application/json; charset=utf-8"}]
157+
:httpc.request(:post, {String.to_charlist(url), headers, ~c"application/json", String.to_charlist(body)}, [timeout: 10_000], [])
158158
|> handle_httpc_response()
159159
end
160160

lib/beacon/seo/json_ld.ex

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,6 @@ defmodule Beacon.SEO.JsonLd do
208208
end)
209209
end
210210

211-
defp format_datetime(%DateTime{} = dt), do: DateTime.to_iso8601(dt)
212-
defp format_datetime(%NaiveDateTime{} = ndt), do: NaiveDateTime.to_iso8601(ndt)
213-
defp format_datetime(str) when is_binary(str), do: str
214-
defp format_datetime(_), do: nil
215211

216212
defp put_if(map, _key, nil), do: map
217213
defp put_if(map, _key, ""), do: map

0 commit comments

Comments
 (0)