Merge branch 'dialyzer-fixes' into 'develop'

Dialyzer and gradient fixes

See merge request pleroma/pleroma!4051
This commit is contained in:
feld 2024-02-04 17:56:14 +00:00
commit 0b9990a7e5
17 changed files with 23 additions and 33 deletions

View File

View File

@ -111,7 +111,7 @@ defmodule Mix.Tasks.Pleroma.Emoji do
{:ok, _} = {:ok, _} =
:zip.unzip(binary_archive, :zip.unzip(binary_archive,
cwd: pack_path, cwd: String.to_charlist(pack_path),
file_list: files_to_unzip file_list: files_to_unzip
) )

View File

@ -256,7 +256,7 @@ defmodule Pleroma.Config.DeprecationWarnings do
move_namespace_and_warn(@mrf_config_map, warning_preface) move_namespace_and_warn(@mrf_config_map, warning_preface)
end end
@spec move_namespace_and_warn([config_map()], String.t()) :: :ok | nil @spec move_namespace_and_warn([config_map()], String.t()) :: :ok | :error
def move_namespace_and_warn(config_map, warning_preface) do def move_namespace_and_warn(config_map, warning_preface) do
warning = warning =
Enum.reduce(config_map, "", fn Enum.reduce(config_map, "", fn
@ -279,7 +279,7 @@ defmodule Pleroma.Config.DeprecationWarnings do
end end
end end
@spec check_media_proxy_whitelist_config() :: :ok | nil @spec check_media_proxy_whitelist_config() :: :ok | :error
def check_media_proxy_whitelist_config do def check_media_proxy_whitelist_config do
whitelist = Config.get([:media_proxy, :whitelist]) whitelist = Config.get([:media_proxy, :whitelist])
@ -340,7 +340,7 @@ defmodule Pleroma.Config.DeprecationWarnings do
end end
end end
@spec check_activity_expiration_config() :: :ok | nil @spec check_activity_expiration_config() :: :ok | :error
def check_activity_expiration_config do def check_activity_expiration_config do
warning_preface = """ warning_preface = """
!!!DEPRECATION WARNING!!! !!!DEPRECATION WARNING!!!
@ -356,7 +356,7 @@ defmodule Pleroma.Config.DeprecationWarnings do
) )
end end
@spec check_remote_ip_plug_name() :: :ok | nil @spec check_remote_ip_plug_name() :: :ok | :error
def check_remote_ip_plug_name do def check_remote_ip_plug_name do
warning_preface = """ warning_preface = """
!!!DEPRECATION WARNING!!! !!!DEPRECATION WARNING!!!
@ -372,7 +372,7 @@ defmodule Pleroma.Config.DeprecationWarnings do
) )
end end
@spec check_uploaders_s3_public_endpoint() :: :ok | nil @spec check_uploaders_s3_public_endpoint() :: :ok | :error
def check_uploaders_s3_public_endpoint do def check_uploaders_s3_public_endpoint do
s3_config = Pleroma.Config.get([Pleroma.Uploaders.S3]) s3_config = Pleroma.Config.get([Pleroma.Uploaders.S3])
@ -393,7 +393,7 @@ defmodule Pleroma.Config.DeprecationWarnings do
end end
end end
@spec check_old_chat_shoutbox() :: :ok | nil @spec check_old_chat_shoutbox() :: :ok | :error
def check_old_chat_shoutbox do def check_old_chat_shoutbox do
instance_config = Pleroma.Config.get([:instance]) instance_config = Pleroma.Config.get([:instance])
chat_config = Pleroma.Config.get([:chat]) || [] chat_config = Pleroma.Config.get([:chat]) || []

View File

@ -100,7 +100,7 @@ defmodule Pleroma.Emoji.Pack do
{:ok, _emoji_files} = {:ok, _emoji_files} =
:zip.unzip( :zip.unzip(
to_charlist(file.path), to_charlist(file.path),
[{:file_list, Enum.map(emojies, & &1[:path])}, {:cwd, tmp_dir}] [{:file_list, Enum.map(emojies, & &1[:path])}, {:cwd, String.to_charlist(tmp_dir)}]
) )
{_, updated_pack} = {_, updated_pack} =

View File

@ -216,9 +216,6 @@ defmodule Pleroma.Filter do
:re -> :re ->
~r/\b#{phrases}\b/i ~r/\b#{phrases}\b/i
_ ->
nil
end end
end end

View File

@ -54,12 +54,12 @@ defmodule Pleroma.HTTP.RequestBuilder do
@doc """ @doc """
Add optional parameters to the request Add optional parameters to the request
""" """
@spec add_param(Request.t(), atom(), atom(), any()) :: Request.t() @spec add_param(Request.t(), atom(), atom() | String.t(), any()) :: Request.t()
def add_param(request, :query, :query, values), do: %{request | query: values} def add_param(request, :query, :query, values), do: %{request | query: values}
def add_param(request, :body, :body, value), do: %{request | body: value} def add_param(request, :body, :body, value), do: %{request | body: value}
def add_param(request, :body, key, value) do def add_param(request, :body, key, value) when is_binary(key) do
request request
|> Map.put(:body, Multipart.new()) |> Map.put(:body, Multipart.new())
|> Map.update!( |> Map.update!(

View File

@ -77,7 +77,7 @@ defmodule Pleroma.MFA do
{:ok, codes} {:ok, codes}
else else
{:error, msg} -> {:error, msg} ->
%{error: msg} {:error, msg}
end end
end end

View File

@ -14,6 +14,7 @@ defmodule Pleroma.MFA.TOTP do
@doc """ @doc """
https://github.com/google/google-authenticator/wiki/Key-Uri-Format https://github.com/google/google-authenticator/wiki/Key-Uri-Format
""" """
@spec provisioning_uri(String.t(), String.t(), list()) :: String.t()
def provisioning_uri(secret, label, opts \\ []) do def provisioning_uri(secret, label, opts \\ []) do
query = query =
%{ %{
@ -27,7 +28,7 @@ defmodule Pleroma.MFA.TOTP do
|> URI.encode_query() |> URI.encode_query()
%URI{scheme: "otpauth", host: "totp", path: "/" <> label, query: query} %URI{scheme: "otpauth", host: "totp", path: "/" <> label, query: query}
|> URI.to_string() |> to_string()
end end
defp default_period, do: Config.get(@config_ns ++ [:period]) defp default_period, do: Config.get(@config_ns ++ [:period])

View File

@ -61,15 +61,16 @@ defmodule Pleroma.Pagination do
|> Repo.all() |> Repo.all()
end end
@spec paginate(Ecto.Query.t(), map(), type(), atom() | nil) :: [Ecto.Schema.t()] @spec paginate_list(list(), keyword()) :: list()
def paginate(query, options, method \\ :keyset, table_binding \\ nil) def paginate_list(list, options) do
def paginate(list, options, _method, _table_binding) when is_list(list) do
offset = options[:offset] || 0 offset = options[:offset] || 0
limit = options[:limit] || 0 limit = options[:limit] || 0
Enum.slice(list, offset, limit) Enum.slice(list, offset, limit)
end end
@spec paginate(Ecto.Query.t(), map(), type(), atom() | nil) :: [Ecto.Schema.t()]
def paginate(query, options, method \\ :keyset, table_binding \\ nil)
def paginate(query, options, :keyset, table_binding) do def paginate(query, options, :keyset, table_binding) do
query query
|> restrict(:min_id, options, table_binding) |> restrict(:min_id, options, table_binding)

View File

@ -20,7 +20,7 @@ defmodule Pleroma.Web.ControllerHelper do
|> json(json) |> json(json)
end end
@spec fetch_integer_param(map(), String.t(), integer() | nil) :: integer() | nil @spec fetch_integer_param(map(), String.t() | atom(), integer() | nil) :: integer() | nil
def fetch_integer_param(params, name, default \\ nil) do def fetch_integer_param(params, name, default \\ nil) do
params params
|> Map.get(name, default) |> Map.get(name, default)

View File

@ -11,8 +11,6 @@ defmodule Pleroma.Web.EmbedController do
alias Pleroma.Web.ActivityPub.Visibility alias Pleroma.Web.ActivityPub.Visibility
plug(:put_layout, :embed)
def show(conn, %{"id" => id}) do def show(conn, %{"id" => id}) do
with %Activity{local: true} = activity <- with %Activity{local: true} = activity <-
Activity.get_by_id_with_object(id), Activity.get_by_id_with_object(id),

View File

@ -156,7 +156,7 @@ defmodule Pleroma.Web.MastodonAPI.SearchController do
tags tags
end end
Pleroma.Pagination.paginate(tags, options) Pleroma.Pagination.paginate_list(tags, options)
end end
defp add_joined_tag(tags) do defp add_joined_tag(tags) do

View File

@ -610,13 +610,8 @@ defmodule Pleroma.Web.OAuth.OAuthController do
end end
end end
@spec validate_scopes(App.t(), map() | list()) :: @spec validate_scopes(App.t(), list()) ::
{:ok, list()} | {:error, :missing_scopes | :unsupported_scopes} {:ok, list()} | {:error, :missing_scopes | :unsupported_scopes}
defp validate_scopes(%App{} = app, params) when is_map(params) do
requested_scopes = Scopes.fetch_scopes(params, app.scopes)
validate_scopes(app, requested_scopes)
end
defp validate_scopes(%App{} = app, requested_scopes) when is_list(requested_scopes) do defp validate_scopes(%App{} = app, requested_scopes) when is_list(requested_scopes) do
Scopes.validate(requested_scopes, app.scopes) Scopes.validate(requested_scopes, app.scopes)
end end

View File

@ -112,7 +112,6 @@ defmodule Pleroma.Web.OStatus.OStatusController do
%{data: %{"attachment" => [%{"url" => [url | _]} | _]}} <- object, %{data: %{"attachment" => [%{"url" => [url | _]} | _]}} <- object,
true <- String.starts_with?(url["mediaType"], ["audio", "video"]) do true <- String.starts_with?(url["mediaType"], ["audio", "video"]) do
conn conn
|> put_layout(:metadata_player)
|> put_resp_header("x-frame-options", "ALLOW") |> put_resp_header("x-frame-options", "ALLOW")
|> put_resp_header( |> put_resp_header(
"content-security-policy", "content-security-policy",

View File

@ -28,7 +28,7 @@ defmodule Pleroma.Web.PleromaAPI.MascotController do
_ _
) do ) do
with {:content_type, "image" <> _} <- {:content_type, file.content_type}, with {:content_type, "image" <> _} <- {:content_type, file.content_type},
{:ok, object} <- ActivityPub.upload(file, actor: User.ap_id(user)) do {_, {:ok, object}} <- {:upload, ActivityPub.upload(file, actor: User.ap_id(user))} do
attachment = render_attachment(object) attachment = render_attachment(object)
{:ok, _user} = User.mascot_update(user, attachment) {:ok, _user} = User.mascot_update(user, attachment)

View File

@ -14,7 +14,7 @@ defmodule Pleroma.Web.Plugs.RateLimiter.Supervisor do
Pleroma.Web.Plugs.RateLimiter.LimiterSupervisor Pleroma.Web.Plugs.RateLimiter.LimiterSupervisor
] ]
opts = [strategy: :one_for_one, name: Pleroma.Web.Streamer.Supervisor] opts = [strategy: :one_for_one]
Supervisor.init(children, opts) Supervisor.init(children, opts)
end end
end end

View File

@ -13,7 +13,6 @@ defmodule Pleroma.Web.StaticFE.StaticFEController do
alias Pleroma.Web.Metadata alias Pleroma.Web.Metadata
alias Pleroma.Web.Router.Helpers alias Pleroma.Web.Router.Helpers
plug(:put_layout, :static_fe)
plug(:assign_id) plug(:assign_id)
@page_keys ["max_id", "min_id", "limit", "since_id", "order"] @page_keys ["max_id", "min_id", "limit", "since_id", "order"]