From: Haelwenn (lanodan) Monnier Date: Wed, 6 Feb 2019 19:19:39 +0000 (+0100) Subject: Credo fixes: parameter consistency X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=106f4e7a0fd70ab04a116238af0322e991cc88c6;p=akkoma Credo fixes: parameter consistency --- diff --git a/lib/pleroma/flake_id.ex b/lib/pleroma/flake_id.ex index 69ab8ccf9..9f098ce33 100644 --- a/lib/pleroma/flake_id.ex +++ b/lib/pleroma/flake_id.ex @@ -27,7 +27,7 @@ defmodule Pleroma.FlakeId do Kernel.to_string(id) 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) end @@ -42,7 +42,7 @@ defmodule Pleroma.FlakeId do def from_string(unquote(Kernel.to_string(i))), do: <<0::integer-size(128)>> 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 case Integer.parse(string) do diff --git a/lib/pleroma/gopher/server.ex b/lib/pleroma/gopher/server.ex index 336142e9b..b47a0697d 100644 --- a/lib/pleroma/gopher/server.ex +++ b/lib/pleroma/gopher/server.ex @@ -47,7 +47,7 @@ defmodule Pleroma.Gopher.Server.ProtocolHandler do {:ok, pid} end - def init(ref, socket, transport, _Opts = []) do + def init(ref, socket, transport, [] = _Opts) do :ok = :ranch.accept_ack(ref) loop(socket, transport) end diff --git a/lib/pleroma/plugs/instance_static.ex b/lib/pleroma/plugs/instance_static.ex index 11f108de7..41125921a 100644 --- a/lib/pleroma/plugs/instance_static.ex +++ b/lib/pleroma/plugs/instance_static.ex @@ -33,7 +33,7 @@ defmodule Pleroma.Plugs.InstanceStatic do for only <- @only do 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( conn, opts, diff --git a/lib/pleroma/plugs/uploaded_media.ex b/lib/pleroma/plugs/uploaded_media.ex index be53ac00c..13aa8641a 100644 --- a/lib/pleroma/plugs/uploaded_media.ex +++ b/lib/pleroma/plugs/uploaded_media.ex @@ -23,7 +23,7 @@ defmodule Pleroma.Plugs.UploadedMedia do %{static_plug_opts: static_plug_opts} 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]) with uploader <- Keyword.fetch!(config, :uploader), diff --git a/lib/pleroma/upload.ex b/lib/pleroma/upload.ex index ce2a1b696..91a5db8c5 100644 --- a/lib/pleroma/upload.ex +++ b/lib/pleroma/upload.ex @@ -180,7 +180,7 @@ defmodule Pleroma.Upload do end # 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 {:ok, %__MODULE__{upload | content_type: content_type}} end diff --git a/lib/pleroma/upload/filter/dedupe.ex b/lib/pleroma/upload/filter/dedupe.ex index 8fcce320f..e4c225833 100644 --- a/lib/pleroma/upload/filter/dedupe.ex +++ b/lib/pleroma/upload/filter/dedupe.ex @@ -6,7 +6,7 @@ defmodule Pleroma.Upload.Filter.Dedupe do @behaviour Pleroma.Upload.Filter alias Pleroma.Upload - def filter(upload = %Upload{name: name}) do + def filter(%Upload{name: name} = upload) do extension = String.split(name, ".") |> List.last() shasum = :crypto.hash(:sha256, File.read!(upload.tempfile)) |> Base.encode16(case: :lower) filename = shasum <> "." <> extension diff --git a/lib/pleroma/uploaders/s3.ex b/lib/pleroma/uploaders/s3.ex index fbd89616c..0038ba01f 100644 --- a/lib/pleroma/uploaders/s3.ex +++ b/lib/pleroma/uploaders/s3.ex @@ -27,7 +27,7 @@ defmodule Pleroma.Uploaders.S3 do ])}} end - def put_file(upload = %Pleroma.Upload{}) do + def put_file(%Pleroma.Upload{} = upload) do config = Pleroma.Config.get([__MODULE__]) bucket = Keyword.get(config, :bucket) diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex index 84be1d4a3..be90b60bc 100644 --- a/lib/pleroma/web/common_api/utils.ex +++ b/lib/pleroma/web/common_api/utils.ex @@ -94,7 +94,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do def make_context(%Activity{data: %{"context" => context}}), do: context 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 add_attachments(text, attachments)