Credo fixes: parameter consistency

This commit is contained in:
Haelwenn (lanodan) Monnier 2019-02-06 20:19:39 +01:00
parent 8bcfac93a8
commit 106f4e7a0f
No known key found for this signature in database
GPG Key ID: D5B7A8E43C997DEE
8 changed files with 9 additions and 9 deletions

View File

@ -27,7 +27,7 @@ defmodule Pleroma.FlakeId do
Kernel.to_string(id) Kernel.to_string(id)
end end
def to_string(flake = <<_::integer-size(64), _::integer-size(48), _::integer-size(16)>>) do def to_string(<<_::integer-size(64), _::integer-size(48), _::integer-size(16)>> = flake) do
encode_base62(flake) encode_base62(flake)
end end
@ -42,7 +42,7 @@ defmodule Pleroma.FlakeId do
def from_string(unquote(Kernel.to_string(i))), do: <<0::integer-size(128)>> def from_string(unquote(Kernel.to_string(i))), do: <<0::integer-size(128)>>
end end
def from_string(flake = <<_::integer-size(128)>>), do: flake def from_string(<<_::integer-size(128)>> = flake), do: flake
def from_string(string) when is_binary(string) and byte_size(string) < 18 do def from_string(string) when is_binary(string) and byte_size(string) < 18 do
case Integer.parse(string) do case Integer.parse(string) do

View File

@ -47,7 +47,7 @@ defmodule Pleroma.Gopher.Server.ProtocolHandler do
{:ok, pid} {:ok, pid}
end end
def init(ref, socket, transport, _Opts = []) do def init(ref, socket, transport, [] = _Opts) do
:ok = :ranch.accept_ack(ref) :ok = :ranch.accept_ack(ref)
loop(socket, transport) loop(socket, transport)
end end

View File

@ -33,7 +33,7 @@ defmodule Pleroma.Plugs.InstanceStatic do
for only <- @only do for only <- @only do
at = Plug.Router.Utils.split("/") at = Plug.Router.Utils.split("/")
def call(conn = %{request_path: "/" <> unquote(only) <> _}, opts) do def call(%{request_path: "/" <> unquote(only) <> _} = conn, opts) do
call_static( call_static(
conn, conn,
opts, opts,

View File

@ -23,7 +23,7 @@ defmodule Pleroma.Plugs.UploadedMedia do
%{static_plug_opts: static_plug_opts} %{static_plug_opts: static_plug_opts}
end end
def call(conn = %{request_path: <<"/", @path, "/", file::binary>>}, opts) do def call(%{request_path: <<"/", @path, "/", file::binary>>} = conn, opts) do
config = Pleroma.Config.get([Pleroma.Upload]) config = Pleroma.Config.get([Pleroma.Upload])
with uploader <- Keyword.fetch!(config, :uploader), with uploader <- Keyword.fetch!(config, :uploader),

View File

@ -180,7 +180,7 @@ defmodule Pleroma.Upload do
end end
# For Mix.Tasks.MigrateLocalUploads # For Mix.Tasks.MigrateLocalUploads
defp prepare_upload(upload = %__MODULE__{tempfile: path}, _opts) do defp prepare_upload(%__MODULE__{tempfile: path} = upload, _opts) do
with {:ok, content_type} <- Pleroma.MIME.file_mime_type(path) do with {:ok, content_type} <- Pleroma.MIME.file_mime_type(path) do
{:ok, %__MODULE__{upload | content_type: content_type}} {:ok, %__MODULE__{upload | content_type: content_type}}
end end

View File

@ -6,7 +6,7 @@ defmodule Pleroma.Upload.Filter.Dedupe do
@behaviour Pleroma.Upload.Filter @behaviour Pleroma.Upload.Filter
alias Pleroma.Upload alias Pleroma.Upload
def filter(upload = %Upload{name: name}) do def filter(%Upload{name: name} = upload) do
extension = String.split(name, ".") |> List.last() extension = String.split(name, ".") |> List.last()
shasum = :crypto.hash(:sha256, File.read!(upload.tempfile)) |> Base.encode16(case: :lower) shasum = :crypto.hash(:sha256, File.read!(upload.tempfile)) |> Base.encode16(case: :lower)
filename = shasum <> "." <> extension filename = shasum <> "." <> extension

View File

@ -27,7 +27,7 @@ defmodule Pleroma.Uploaders.S3 do
])}} ])}}
end end
def put_file(upload = %Pleroma.Upload{}) do def put_file(%Pleroma.Upload{} = upload) do
config = Pleroma.Config.get([__MODULE__]) config = Pleroma.Config.get([__MODULE__])
bucket = Keyword.get(config, :bucket) bucket = Keyword.get(config, :bucket)

View File

@ -94,7 +94,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do
def make_context(%Activity{data: %{"context" => context}}), do: context def make_context(%Activity{data: %{"context" => context}}), do: context
def make_context(_), do: Utils.generate_context_id() def make_context(_), do: Utils.generate_context_id()
def maybe_add_attachments(text, _attachments, _no_links = true), do: text def maybe_add_attachments(text, _attachments, true = _no_links), do: text
def maybe_add_attachments(text, attachments, _no_links) do def maybe_add_attachments(text, attachments, _no_links) do
add_attachments(text, attachments) add_attachments(text, attachments)