Pleroma.Web.MediaProxy.MediaProxyController: dialyzer errors

lib/pleroma/web/media_proxy/media_proxy_controller.ex:55:no_return
Function handle_preview/2 has no local return.
________________________________________________________________________________
lib/pleroma/web/media_proxy/media_proxy_controller.ex:59:call
The function call will not succeed.

Pleroma.HTTP.request(<<72, 69, 65, 68>>, _media_proxy_url :: any(), [], [], [{:pool, :media}])

will never return since the success typing is:
(
  :delete | :get | :head | :options | :patch | :post | :put | :trace,
  binary(),
  any(),
  [{binary(), binary()}],
  Keyword.t()
) :: any()

and the contract is
(
  method(),
  Pleroma.HTTP.Request.url(),
  String.t(),
  Pleroma.HTTP.Request.headers(),
  :elixir.keyword()
) :: {:ok, Tesla.Env.t()} | {:error, any()}

________________________________________________________________________________
lib/pleroma/web/media_proxy/media_proxy_controller.ex:95:unused_fun
Function handle_preview/3 will never be called.
________________________________________________________________________________
lib/pleroma/web/media_proxy/media_proxy_controller.ex:111:unused_fun
Function handle_png_preview/2 will never be called.
________________________________________________________________________________
lib/pleroma/web/media_proxy/media_proxy_controller.ex:134:unused_fun
Function handle_jpeg_preview/2 will never be called.
________________________________________________________________________________
lib/pleroma/web/media_proxy/media_proxy_controller.ex:152:unused_fun
Function handle_video_preview/2 will never be called.
________________________________________________________________________________
lib/pleroma/web/media_proxy/media_proxy_controller.ex:164:unused_fun
Function drop_static_param_and_redirect/1 will never be called.
________________________________________________________________________________
lib/pleroma/web/media_proxy/media_proxy_controller.ex:173:unused_fun
Function fallback_on_preview_error/2 will never be called.
________________________________________________________________________________
lib/pleroma/web/media_proxy/media_proxy_controller.ex:177:unused_fun
Function put_preview_response_headers/1 will never be called.
________________________________________________________________________________
lib/pleroma/web/media_proxy/media_proxy_controller.ex:177:unused_fun
Function put_preview_response_headers/2 will never be called.
________________________________________________________________________________
lib/pleroma/web/media_proxy/media_proxy_controller.ex:187:unused_fun
Function thumbnail_max_dimensions/0 will never be called.
________________________________________________________________________________
lib/pleroma/web/media_proxy/media_proxy_controller.ex:196:unused_fun
Function min_content_length_for_preview/0 will never be called.
________________________________________________________________________________
lib/pleroma/web/media_proxy/media_proxy_controller.ex:200:unused_fun
Function media_preview_proxy_config/0 will never be called.
This commit is contained in:
Mark Felder 2024-01-29 18:47:54 -05:00
parent 8cd5279857
commit b666710574
2 changed files with 10 additions and 10 deletions

View File

@ -56,7 +56,7 @@ defp handle_preview(conn, url) do
media_proxy_url = MediaProxy.url(url)
with {:ok, %{status: status} = head_response} when status in 200..299 <-
Pleroma.HTTP.request("HEAD", media_proxy_url, [], [], pool: :media) do
Pleroma.HTTP.request(:head, media_proxy_url, "", [], pool: :media) do
content_type = Tesla.get_header(head_response, "content-type")
content_length = Tesla.get_header(head_response, "content-length")
content_length = content_length && String.to_integer(content_length)

View File

@ -182,7 +182,7 @@ test "responds with 424 Failed Dependency if HEAD request to media proxy fails",
media_proxy_url: media_proxy_url
} do
Tesla.Mock.mock(fn
%{method: "HEAD", url: ^media_proxy_url} ->
%{method: :head, url: ^media_proxy_url} ->
%Tesla.Env{status: 500, body: ""}
end)
@ -197,7 +197,7 @@ test "redirects to media proxy URI on unsupported content type", %{
media_proxy_url: media_proxy_url
} do
Tesla.Mock.mock(fn
%{method: "HEAD", url: ^media_proxy_url} ->
%{method: :head, url: ^media_proxy_url} ->
%Tesla.Env{status: 200, body: "", headers: [{"content-type", "application/pdf"}]}
end)
@ -217,7 +217,7 @@ test "with `static=true` and GIF image preview requested, responds with JPEG ima
clear_config([:media_preview_proxy, :min_content_length], 1_000_000_000)
Tesla.Mock.mock(fn
%{method: "HEAD", url: ^media_proxy_url} ->
%{method: :head, url: ^media_proxy_url} ->
%Tesla.Env{
status: 200,
body: "",
@ -242,7 +242,7 @@ test "with GIF image preview requested and no `static` param, redirects to media
media_proxy_url: media_proxy_url
} do
Tesla.Mock.mock(fn
%{method: "HEAD", url: ^media_proxy_url} ->
%{method: :head, url: ^media_proxy_url} ->
%Tesla.Env{status: 200, body: "", headers: [{"content-type", "image/gif"}]}
end)
@ -260,7 +260,7 @@ test "with `static` param and non-GIF image preview requested, " <>
media_proxy_url: media_proxy_url
} do
Tesla.Mock.mock(fn
%{method: "HEAD", url: ^media_proxy_url} ->
%{method: :head, url: ^media_proxy_url} ->
%Tesla.Env{status: 200, body: "", headers: [{"content-type", "image/jpeg"}]}
end)
@ -280,7 +280,7 @@ test "with :min_content_length setting not matched by Content-Length header, " <
clear_config([:media_preview_proxy, :min_content_length], 100_000)
Tesla.Mock.mock(fn
%{method: "HEAD", url: ^media_proxy_url} ->
%{method: :head, url: ^media_proxy_url} ->
%Tesla.Env{
status: 200,
body: "",
@ -302,7 +302,7 @@ test "thumbnails PNG images into PNG", %{
assert_dependencies_installed()
Tesla.Mock.mock(fn
%{method: "HEAD", url: ^media_proxy_url} ->
%{method: :head, url: ^media_proxy_url} ->
%Tesla.Env{status: 200, body: "", headers: [{"content-type", "image/png"}]}
%{method: :get, url: ^media_proxy_url} ->
@ -324,7 +324,7 @@ test "thumbnails JPEG images into JPEG", %{
assert_dependencies_installed()
Tesla.Mock.mock(fn
%{method: "HEAD", url: ^media_proxy_url} ->
%{method: :head, url: ^media_proxy_url} ->
%Tesla.Env{status: 200, body: "", headers: [{"content-type", "image/jpeg"}]}
%{method: :get, url: ^media_proxy_url} ->
@ -344,7 +344,7 @@ test "redirects to media proxy URI in case of thumbnailing error", %{
media_proxy_url: media_proxy_url
} do
Tesla.Mock.mock(fn
%{method: "HEAD", url: ^media_proxy_url} ->
%{method: :head, url: ^media_proxy_url} ->
%Tesla.Env{status: 200, body: "", headers: [{"content-type", "image/jpeg"}]}
%{method: :get, url: ^media_proxy_url} ->