Commit 8bcfac93 authored by Haelwenn's avatar Haelwenn

Make credo happy

parent c5f8df08
......@@ -57,7 +57,7 @@
# For some checks, like AliasUsage, you can only customize the priority
# Priority values are: `low, normal, high, higher`
{Credo.Check.Design.AliasUsage, priority: :low},
{Credo.Check.Design.AliasUsage, priority: :low, if_called_more_often_than: 3},
# For others you can set parameters
......
......@@ -211,7 +211,7 @@ defmodule Mix.Tasks.Pleroma.User do
user = Repo.get(User, user.id)
if length(user.following) == 0 do
if Enum.empty?(user.following) do
Mix.shell().info("Successfully unsubscribed all followers from #{user.nickname}")
end
else
......
......@@ -23,7 +23,7 @@ defmodule Pleroma.Stats do
def schedule_update do
spawn(fn ->
# 1 hour
Process.sleep(1000 * 60 * 60 * 1)
Process.sleep(1000 * 60 * 60)
schedule_update()
end)
......
......@@ -119,7 +119,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
activity.data["object"]
|> Map.get("tag", [])
|> Enum.filter(fn tag -> is_bitstring(tag) end)
|> Enum.map(fn tag -> Pleroma.Web.Streamer.stream("hashtag:" <> tag, activity) end)
|> Enum.each(fn tag -> Pleroma.Web.Streamer.stream("hashtag:" <> tag, activity) end)
if activity.data["object"]["attachment"] != [] do
Pleroma.Web.Streamer.stream("public:media", activity)
......
......@@ -6,8 +6,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do
alias Calendar.Strftime
alias Comeonin.Pbkdf2
alias Pleroma.{Activity, Formatter, Object, Repo}
alias Pleroma.User
alias Pleroma.Web
alias Pleroma.{User, Web}
alias Pleroma.Web.ActivityPub.Utils
alias Pleroma.Web.Endpoint
alias Pleroma.Web.MediaProxy
......
......@@ -25,7 +25,7 @@ defmodule Pleroma.Web.Federator do
def start_link do
spawn(fn ->
# 1 minute
Process.sleep(1000 * 60 * 1)
Process.sleep(1000 * 60)
enqueue(:refresh_subscriptions, nil)
end)
......@@ -197,7 +197,6 @@ defmodule Pleroma.Web.Federator do
end
def handle_cast(m, state) do
IO.inspect("Unknown: #{inspect(m)}, #{inspect(state)}")
{:noreply, state}
end
......
......@@ -4,11 +4,11 @@
defmodule Pleroma.Web.MastodonAPI.AccountView do
use Pleroma.Web, :view
alias Pleroma.User
alias Pleroma.Web.MastodonAPI.AccountView
alias Pleroma.{HTML, User}
alias Pleroma.Web.CommonAPI.Utils
alias Pleroma.Web.MastodonAPI.AccountView
alias Pleroma.Web.MediaProxy
alias Pleroma.HTML
def render("accounts.json", %{users: users} = opts) do
users
......
......@@ -4,8 +4,8 @@
defmodule Pleroma.Web.MastodonAPI.FilterView do
use Pleroma.Web, :view
alias Pleroma.Web.MastodonAPI.FilterView
alias Pleroma.Web.CommonAPI.Utils
alias Pleroma.Web.MastodonAPI.FilterView
def render("filters.json", %{filters: filters} = opts) do
render_many(filters, FilterView, "filter.json", opts)
......
......@@ -5,14 +5,10 @@
defmodule Pleroma.Web.MastodonAPI.StatusView do
use Pleroma.Web, :view
alias Pleroma.Activity
alias Pleroma.HTML
alias Pleroma.Repo
alias Pleroma.User
alias Pleroma.{Activity, HTML, Repo, User}
alias Pleroma.Web.CommonAPI.Utils
alias Pleroma.Web.MastodonAPI.{AccountView, StatusView}
alias Pleroma.Web.MediaProxy
alias Pleroma.Web.MastodonAPI.AccountView
alias Pleroma.Web.MastodonAPI.StatusView
# TODO: Add cached version.
defp get_replied_to_activities(activities) do
......
......@@ -6,7 +6,7 @@ defmodule Pleroma.Web.MastodonAPI.WebsocketHandler do
require Logger
alias Pleroma.Web.OAuth.Token
alias Pleroma.{User, Repo}
alias Pleroma.{Repo, User}
@behaviour :cowboy_websocket_handler
......
......@@ -4,11 +4,12 @@
defmodule Pleroma.Web.MediaProxy.MediaProxyController do
use Pleroma.Web, :controller
alias Pleroma.{Web.MediaProxy, ReverseProxy}
alias Pleroma.ReverseProxy
alias Pleroma.Web.MediaProxy
@default_proxy_opts [max_body_length: 25 * 1_048_576, http: [follow_redirect: true]]
def remote(conn, params = %{"sig" => sig64, "url" => url64}) do
def remote(conn, %{"sig" => sig64, "url" => url64} = params) do
with config <- Pleroma.Config.get([:media_proxy], []),
true <- Keyword.get(config, :enabled, false),
{:ok, url} <- MediaProxy.decode_url(sig64, url64),
......
......@@ -9,7 +9,7 @@ defmodule Pleroma.Web.MediaProxy do
def url(""), do: nil
def url(url = "/" <> _), do: url
def url("/" <> _ = url), do: url
def url(url) do
config = Application.get_env(:pleroma, :media_proxy, [])
......
......@@ -5,10 +5,7 @@
defmodule Pleroma.Web.Nodeinfo.NodeinfoController do
use Pleroma.Web, :controller
alias Pleroma.Stats
alias Pleroma.Web
alias Pleroma.{User, Repo}
alias Pleroma.Config
alias Pleroma.{Config, Repo, Stats, User, Web}
alias Pleroma.Web.ActivityPub.MRF
plug(Pleroma.Web.FederatingPlug)
......@@ -32,7 +29,7 @@ defmodule Pleroma.Web.Nodeinfo.NodeinfoController do
# returns a nodeinfo 2.0 map, since 2.1 just adds a repository field
# under software.
def raw_nodeinfo() do
def raw_nodeinfo do
instance = Application.get_env(:pleroma, :instance)
media_proxy = Application.get_env(:pleroma, :media_proxy)
suggestions = Application.get_env(:pleroma, :suggestions)
......@@ -66,10 +63,8 @@ defmodule Pleroma.Web.Nodeinfo.NodeinfoController do
Config.get([:mrf_user_allowlist], [])
|> Enum.into(%{}, fn {k, v} -> {k, length(v)} end)
mrf_transparency = Keyword.get(instance, :mrf_transparency)
federation_response =
if mrf_transparency do
if Keyword.get(instance, :mrf_transparency) do
%{
mrf_policies: mrf_policies,
mrf_simple: mrf_simple,
......
......@@ -3,7 +3,7 @@ defmodule Pleroma.Web.UploaderController do
alias Pleroma.Uploaders.Uploader
def callback(conn, params = %{"upload_path" => upload_path}) do
def callback(conn, %{"upload_path" => upload_path} = params) do
process_callback(conn, :global.whereis_name({Uploader, upload_path}), params)
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment