[Credo] Remove parentesis on argument-less functions
This commit is contained in:
parent
a3a9cec483
commit
fb82f6fc7c
@ -11,10 +11,10 @@ defmodule Pleroma.Application do
|
|||||||
@repository Mix.Project.config()[:source_url]
|
@repository Mix.Project.config()[:source_url]
|
||||||
def name, do: @name
|
def name, do: @name
|
||||||
def version, do: @version
|
def version, do: @version
|
||||||
def named_version(), do: @name <> " " <> @version
|
def named_version, do: @name <> " " <> @version
|
||||||
def repository, do: @repository
|
def repository, do: @repository
|
||||||
|
|
||||||
def user_agent() do
|
def user_agent do
|
||||||
info = "#{Pleroma.Web.base_url()} <#{Pleroma.Config.get([:instance, :email], "")}>"
|
info = "#{Pleroma.Web.base_url()} <#{Pleroma.Config.get([:instance, :email], "")}>"
|
||||||
named_version() <> "; " <> info
|
named_version() <> "; " <> info
|
||||||
end
|
end
|
||||||
@ -127,7 +127,7 @@ defmodule Pleroma.Application do
|
|||||||
Supervisor.start_link(children, opts)
|
Supervisor.start_link(children, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
def enabled_hackney_pools() do
|
def enabled_hackney_pools do
|
||||||
[:media] ++
|
[:media] ++
|
||||||
if Application.get_env(:tesla, :adapter) == Tesla.Adapter.Hackney do
|
if Application.get_env(:tesla, :adapter) == Tesla.Adapter.Hackney do
|
||||||
[:federation]
|
[:federation]
|
||||||
@ -142,14 +142,14 @@ defmodule Pleroma.Application do
|
|||||||
end
|
end
|
||||||
|
|
||||||
if Mix.env() == :test do
|
if Mix.env() == :test do
|
||||||
defp streamer_child(), do: []
|
defp streamer_child, do: []
|
||||||
defp chat_child(), do: []
|
defp chat_child, do: []
|
||||||
else
|
else
|
||||||
defp streamer_child() do
|
defp streamer_child do
|
||||||
[worker(Pleroma.Web.Streamer, [])]
|
[worker(Pleroma.Web.Streamer, [])]
|
||||||
end
|
end
|
||||||
|
|
||||||
defp chat_child() do
|
defp chat_child do
|
||||||
if Pleroma.Config.get([:chat, :enabled]) do
|
if Pleroma.Config.get([:chat, :enabled]) do
|
||||||
[worker(Pleroma.Web.ChatChannel.ChatChannelState, [])]
|
[worker(Pleroma.Web.ChatChannel.ChatChannelState, [])]
|
||||||
else
|
else
|
||||||
@ -158,7 +158,7 @@ defmodule Pleroma.Application do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp hackney_pool_children() do
|
defp hackney_pool_children do
|
||||||
for pool <- enabled_hackney_pools() do
|
for pool <- enabled_hackney_pools() do
|
||||||
options = Pleroma.Config.get([:hackney_pools, pool])
|
options = Pleroma.Config.get([:hackney_pools, pool])
|
||||||
:hackney_pool.child_spec(pool, options)
|
:hackney_pool.child_spec(pool, options)
|
||||||
|
@ -10,7 +10,7 @@ defmodule Pleroma.Captcha do
|
|||||||
use GenServer
|
use GenServer
|
||||||
|
|
||||||
@doc false
|
@doc false
|
||||||
def start_link() do
|
def start_link do
|
||||||
GenServer.start_link(__MODULE__, [], name: __MODULE__)
|
GenServer.start_link(__MODULE__, [], name: __MODULE__)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ defmodule Pleroma.Captcha do
|
|||||||
@doc """
|
@doc """
|
||||||
Ask the configured captcha service for a new captcha
|
Ask the configured captcha service for a new captcha
|
||||||
"""
|
"""
|
||||||
def new() do
|
def new do
|
||||||
GenServer.call(__MODULE__, :new)
|
GenServer.call(__MODULE__, :new)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ defmodule Pleroma.Captcha.Kocaptcha do
|
|||||||
@behaviour Service
|
@behaviour Service
|
||||||
|
|
||||||
@impl Service
|
@impl Service
|
||||||
def new() do
|
def new do
|
||||||
endpoint = Pleroma.Config.get!([__MODULE__, :endpoint])
|
endpoint = Pleroma.Config.get!([__MODULE__, :endpoint])
|
||||||
|
|
||||||
case Tesla.get(endpoint <> "/new") do
|
case Tesla.get(endpoint <> "/new") do
|
||||||
|
@ -7,13 +7,13 @@ defmodule Pleroma.Clippy do
|
|||||||
# No software is complete until they have a Clippy implementation.
|
# No software is complete until they have a Clippy implementation.
|
||||||
# A ballmer peak _may_ be required to change this module.
|
# A ballmer peak _may_ be required to change this module.
|
||||||
|
|
||||||
def tip() do
|
def tip do
|
||||||
tips()
|
tips()
|
||||||
|> Enum.random()
|
|> Enum.random()
|
||||||
|> puts()
|
|> puts()
|
||||||
end
|
end
|
||||||
|
|
||||||
def tips() do
|
def tips do
|
||||||
host = Pleroma.Config.get([Pleroma.Web.Endpoint, :url, :host])
|
host = Pleroma.Config.get([Pleroma.Web.Endpoint, :url, :host])
|
||||||
|
|
||||||
[
|
[
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
defmodule Pleroma.Config.DeprecationWarnings do
|
defmodule Pleroma.Config.DeprecationWarnings do
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
def check_frontend_config_mechanism() do
|
def check_frontend_config_mechanism do
|
||||||
if Pleroma.Config.get(:fe) do
|
if Pleroma.Config.get(:fe) do
|
||||||
Logger.warn("""
|
Logger.warn("""
|
||||||
!!!DEPRECATION WARNING!!!
|
!!!DEPRECATION WARNING!!!
|
||||||
|
@ -17,13 +17,13 @@ defmodule Pleroma.Emoji do
|
|||||||
@ets_options [:ordered_set, :protected, :named_table, {:read_concurrency, true}]
|
@ets_options [:ordered_set, :protected, :named_table, {:read_concurrency, true}]
|
||||||
|
|
||||||
@doc false
|
@doc false
|
||||||
def start_link() do
|
def start_link do
|
||||||
GenServer.start_link(__MODULE__, [], name: __MODULE__)
|
GenServer.start_link(__MODULE__, [], name: __MODULE__)
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc "Reloads the emojis from disk."
|
@doc "Reloads the emojis from disk."
|
||||||
@spec reload() :: :ok
|
@spec reload() :: :ok
|
||||||
def reload() do
|
def reload do
|
||||||
GenServer.call(__MODULE__, :reload)
|
GenServer.call(__MODULE__, :reload)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ defmodule Pleroma.Emoji do
|
|||||||
|
|
||||||
@doc "Returns all the emojos!!"
|
@doc "Returns all the emojos!!"
|
||||||
@spec get_all() :: [{String.t(), String.t()}, ...]
|
@spec get_all() :: [{String.t(), String.t()}, ...]
|
||||||
def get_all() do
|
def get_all do
|
||||||
:ets.tab2list(@ets)
|
:ets.tab2list(@ets)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ defmodule Pleroma.Emoji do
|
|||||||
{:ok, state}
|
{:ok, state}
|
||||||
end
|
end
|
||||||
|
|
||||||
defp load() do
|
defp load do
|
||||||
emojis =
|
emojis =
|
||||||
(load_finmoji(Keyword.get(Application.get_env(:pleroma, :instance), :finmoji_enabled)) ++
|
(load_finmoji(Keyword.get(Application.get_env(:pleroma, :instance), :finmoji_enabled)) ++
|
||||||
load_from_file("config/emoji.txt") ++
|
load_from_file("config/emoji.txt") ++
|
||||||
|
@ -85,7 +85,7 @@ defmodule Pleroma.FlakeId do
|
|||||||
{:ok, FlakeId.from_string(value)}
|
{:ok, FlakeId.from_string(value)}
|
||||||
end
|
end
|
||||||
|
|
||||||
def autogenerate(), do: get()
|
def autogenerate, do: get()
|
||||||
|
|
||||||
# -- GenServer API
|
# -- GenServer API
|
||||||
def start_link do
|
def start_link do
|
||||||
@ -165,7 +165,7 @@ defmodule Pleroma.FlakeId do
|
|||||||
1_000_000_000 * mega_seconds + seconds * 1000 + :erlang.trunc(micro_seconds / 1000)
|
1_000_000_000 * mega_seconds + seconds * 1000 + :erlang.trunc(micro_seconds / 1000)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp worker_id() do
|
defp worker_id do
|
||||||
<<worker::integer-size(48)>> = :crypto.strong_rand_bytes(6)
|
<<worker::integer-size(48)>> = :crypto.strong_rand_bytes(6)
|
||||||
worker
|
worker
|
||||||
end
|
end
|
||||||
|
@ -6,7 +6,7 @@ defmodule Pleroma.Gopher.Server do
|
|||||||
use GenServer
|
use GenServer
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
def start_link() do
|
def start_link do
|
||||||
config = Pleroma.Config.get(:gopher, [])
|
config = Pleroma.Config.get(:gopher, [])
|
||||||
ip = Keyword.get(config, :ip, {0, 0, 0, 0})
|
ip = Keyword.get(config, :ip, {0, 0, 0, 0})
|
||||||
port = Keyword.get(config, :port, 1234)
|
port = Keyword.get(config, :port, 1234)
|
||||||
|
@ -9,7 +9,7 @@ defmodule Pleroma.HTML do
|
|||||||
defp get_scrubbers(scrubbers) when is_list(scrubbers), do: scrubbers
|
defp get_scrubbers(scrubbers) when is_list(scrubbers), do: scrubbers
|
||||||
defp get_scrubbers(_), do: [Pleroma.HTML.Scrubber.Default]
|
defp get_scrubbers(_), do: [Pleroma.HTML.Scrubber.Default]
|
||||||
|
|
||||||
def get_scrubbers() do
|
def get_scrubbers do
|
||||||
Pleroma.Config.get([:markup, :scrub_policy])
|
Pleroma.Config.get([:markup, :scrub_policy])
|
||||||
|> get_scrubbers
|
|> get_scrubbers
|
||||||
end
|
end
|
||||||
|
@ -17,7 +17,7 @@ defmodule Pleroma.Uploaders.Swift.Keystone do
|
|||||||
|> Poison.decode!()
|
|> Poison.decode!()
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_token() do
|
def get_token do
|
||||||
settings = Pleroma.Config.get(Pleroma.Uploaders.Swift)
|
settings = Pleroma.Config.get(Pleroma.Uploaders.Swift)
|
||||||
username = Keyword.fetch!(settings, :username)
|
username = Keyword.fetch!(settings, :username)
|
||||||
password = Keyword.fetch!(settings, :password)
|
password = Keyword.fetch!(settings, :password)
|
||||||
|
@ -1340,7 +1340,7 @@ defmodule Pleroma.User do
|
|||||||
|> Enum.map(&String.downcase(&1))
|
|> Enum.map(&String.downcase(&1))
|
||||||
end
|
end
|
||||||
|
|
||||||
defp local_nickname_regex() do
|
defp local_nickname_regex do
|
||||||
if Pleroma.Config.get([:instance, :extended_nickname_format]) do
|
if Pleroma.Config.get([:instance, :extended_nickname_format]) do
|
||||||
@extended_local_nickname_regex
|
@extended_local_nickname_regex
|
||||||
else
|
else
|
||||||
|
@ -14,7 +14,7 @@ defmodule Pleroma.User.WelcomeMessage do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp welcome_user() do
|
defp welcome_user do
|
||||||
with nickname when is_binary(nickname) <-
|
with nickname when is_binary(nickname) <-
|
||||||
Pleroma.Config.get([:instance, :welcome_user_nickname]),
|
Pleroma.Config.get([:instance, :welcome_user_nickname]),
|
||||||
%User{local: true} = user <- User.get_cached_by_nickname(nickname) do
|
%User{local: true} = user <- User.get_cached_by_nickname(nickname) do
|
||||||
@ -24,7 +24,7 @@ defmodule Pleroma.User.WelcomeMessage do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp welcome_message() do
|
defp welcome_message do
|
||||||
Pleroma.Config.get([:instance, :welcome_message])
|
Pleroma.Config.get([:instance, :welcome_message])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -16,7 +16,7 @@ defmodule Pleroma.Web.ActivityPub.MRF do
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_policies() do
|
def get_policies do
|
||||||
Application.get_env(:pleroma, :instance, [])
|
Application.get_env(:pleroma, :instance, [])
|
||||||
|> Keyword.get(:rewrite_policy, [])
|
|> Keyword.get(:rewrite_policy, [])
|
||||||
|> get_policies()
|
|> get_policies()
|
||||||
|
@ -48,7 +48,7 @@ defmodule Pleroma.Web.ChatChannel.ChatChannelState do
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
def messages() do
|
def messages do
|
||||||
Agent.get(__MODULE__, fn state -> state[:messages] |> Enum.reverse() end)
|
Agent.get(__MODULE__, fn state -> state[:messages] |> Enum.reverse() end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -22,7 +22,7 @@ defmodule Pleroma.Web.Federator do
|
|||||||
@websub Application.get_env(:pleroma, :websub)
|
@websub Application.get_env(:pleroma, :websub)
|
||||||
@ostatus Application.get_env(:pleroma, :ostatus)
|
@ostatus Application.get_env(:pleroma, :ostatus)
|
||||||
|
|
||||||
def init() do
|
def init do
|
||||||
# 1 minute
|
# 1 minute
|
||||||
Process.sleep(1000 * 60)
|
Process.sleep(1000 * 60)
|
||||||
refresh_subscriptions()
|
refresh_subscriptions()
|
||||||
@ -58,7 +58,7 @@ defmodule Pleroma.Web.Federator do
|
|||||||
Jobs.enqueue(:federator_outgoing, __MODULE__, [:request_subscription, sub])
|
Jobs.enqueue(:federator_outgoing, __MODULE__, [:request_subscription, sub])
|
||||||
end
|
end
|
||||||
|
|
||||||
def refresh_subscriptions() do
|
def refresh_subscriptions do
|
||||||
Jobs.enqueue(:federator_outgoing, __MODULE__, [:refresh_subscriptions])
|
Jobs.enqueue(:federator_outgoing, __MODULE__, [:refresh_subscriptions])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ defmodule Pleroma.Web.Federator.RetryQueue do
|
|||||||
{:ok, %{args | queue_table: queue_table, running_jobs: :sets.new()}}
|
{:ok, %{args | queue_table: queue_table, running_jobs: :sets.new()}}
|
||||||
end
|
end
|
||||||
|
|
||||||
def start_link() do
|
def start_link do
|
||||||
enabled =
|
enabled =
|
||||||
if Mix.env() == :test, do: true, else: Pleroma.Config.get([__MODULE__, :enabled], false)
|
if Mix.env() == :test, do: true, else: Pleroma.Config.get([__MODULE__, :enabled], false)
|
||||||
|
|
||||||
@ -39,11 +39,11 @@ defmodule Pleroma.Web.Federator.RetryQueue do
|
|||||||
GenServer.cast(__MODULE__, {:maybe_enqueue, data, transport, retries + 1})
|
GenServer.cast(__MODULE__, {:maybe_enqueue, data, transport, retries + 1})
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_stats() do
|
def get_stats do
|
||||||
GenServer.call(__MODULE__, :get_stats)
|
GenServer.call(__MODULE__, :get_stats)
|
||||||
end
|
end
|
||||||
|
|
||||||
def reset_stats() do
|
def reset_stats do
|
||||||
GenServer.call(__MODULE__, :reset_stats)
|
GenServer.call(__MODULE__, :reset_stats)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ defmodule Pleroma.Web.Federator.RetryQueue do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_retry_timer_interval() do
|
def get_retry_timer_interval do
|
||||||
Pleroma.Config.get([:retry_queue, :interval], 1000)
|
Pleroma.Config.get([:retry_queue, :interval], 1000)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -231,7 +231,7 @@ defmodule Pleroma.Web.Federator.RetryQueue do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp maybe_kickoff_timer() do
|
defp maybe_kickoff_timer do
|
||||||
GenServer.cast(__MODULE__, :kickoff_timer)
|
GenServer.cast(__MODULE__, :kickoff_timer)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1274,7 +1274,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp get_or_make_app() do
|
defp get_or_make_app do
|
||||||
find_attrs = %{client_name: @local_mastodon_name, redirect_uris: "."}
|
find_attrs = %{client_name: @local_mastodon_name, redirect_uris: "."}
|
||||||
scopes = ["read", "write", "follow", "push"]
|
scopes = ["read", "write", "follow", "push"]
|
||||||
|
|
||||||
|
@ -13,15 +13,15 @@ defmodule Pleroma.Web.Push do
|
|||||||
# Client API #
|
# Client API #
|
||||||
##############
|
##############
|
||||||
|
|
||||||
def start_link() do
|
def start_link do
|
||||||
GenServer.start_link(__MODULE__, :ok, name: __MODULE__)
|
GenServer.start_link(__MODULE__, :ok, name: __MODULE__)
|
||||||
end
|
end
|
||||||
|
|
||||||
def vapid_config() do
|
def vapid_config do
|
||||||
Application.get_env(:web_push_encryption, :vapid_details, [])
|
Application.get_env(:web_push_encryption, :vapid_details, [])
|
||||||
end
|
end
|
||||||
|
|
||||||
def enabled() do
|
def enabled do
|
||||||
case vapid_config() do
|
case vapid_config() do
|
||||||
[] -> false
|
[] -> false
|
||||||
list when is_list(list) -> true
|
list when is_list(list) -> true
|
||||||
|
@ -7,7 +7,7 @@ defmodule Pleroma.Captcha.Mock do
|
|||||||
@behaviour Service
|
@behaviour Service
|
||||||
|
|
||||||
@impl Service
|
@impl Service
|
||||||
def new(), do: %{type: :mock}
|
def new, do: %{type: :mock}
|
||||||
|
|
||||||
@impl Service
|
@impl Service
|
||||||
def validate(_token, _captcha, _data), do: :ok
|
def validate(_token, _captcha, _data), do: :ok
|
||||||
|
Loading…
Reference in New Issue
Block a user