From fb82f6fc7c5453e34e619c54a88e64e99deb58b4 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Tue, 5 Mar 2019 04:18:43 +0100 Subject: [PATCH] [Credo] Remove parentesis on argument-less functions --- lib/pleroma/application.ex | 16 ++++++++-------- lib/pleroma/captcha/captcha.ex | 4 ++-- lib/pleroma/captcha/kocaptcha.ex | 2 +- lib/pleroma/clippy.ex | 4 ++-- lib/pleroma/config/deprecation_warnings.ex | 2 +- lib/pleroma/emoji.ex | 8 ++++---- lib/pleroma/flake_id.ex | 4 ++-- lib/pleroma/gopher/server.ex | 2 +- lib/pleroma/html.ex | 2 +- lib/pleroma/uploaders/swift/keystone.ex | 2 +- lib/pleroma/user.ex | 2 +- lib/pleroma/user/welcome_message.ex | 4 ++-- lib/pleroma/web/activity_pub/mrf.ex | 2 +- lib/pleroma/web/chat_channel.ex | 2 +- lib/pleroma/web/federator/federator.ex | 4 ++-- lib/pleroma/web/federator/retry_queue.ex | 10 +++++----- .../web/mastodon_api/mastodon_api_controller.ex | 2 +- lib/pleroma/web/push/push.ex | 6 +++--- test/support/captcha_mock.ex | 2 +- 19 files changed, 40 insertions(+), 40 deletions(-) diff --git a/lib/pleroma/application.ex b/lib/pleroma/application.ex index d2523c045..8756e9469 100644 --- a/lib/pleroma/application.ex +++ b/lib/pleroma/application.ex @@ -11,10 +11,10 @@ defmodule Pleroma.Application do @repository Mix.Project.config()[:source_url] def name, do: @name def version, do: @version - def named_version(), do: @name <> " " <> @version + def named_version, do: @name <> " " <> @version def repository, do: @repository - def user_agent() do + def user_agent do info = "#{Pleroma.Web.base_url()} <#{Pleroma.Config.get([:instance, :email], "")}>" named_version() <> "; " <> info end @@ -127,7 +127,7 @@ def start(_type, _args) do Supervisor.start_link(children, opts) end - def enabled_hackney_pools() do + def enabled_hackney_pools do [:media] ++ if Application.get_env(:tesla, :adapter) == Tesla.Adapter.Hackney do [:federation] @@ -142,14 +142,14 @@ def enabled_hackney_pools() do end if Mix.env() == :test do - defp streamer_child(), do: [] - defp chat_child(), do: [] + defp streamer_child, do: [] + defp chat_child, do: [] else - defp streamer_child() do + defp streamer_child do [worker(Pleroma.Web.Streamer, [])] end - defp chat_child() do + defp chat_child do if Pleroma.Config.get([:chat, :enabled]) do [worker(Pleroma.Web.ChatChannel.ChatChannelState, [])] else @@ -158,7 +158,7 @@ defp chat_child() do end end - defp hackney_pool_children() do + defp hackney_pool_children do for pool <- enabled_hackney_pools() do options = Pleroma.Config.get([:hackney_pools, pool]) :hackney_pool.child_spec(pool, options) diff --git a/lib/pleroma/captcha/captcha.ex b/lib/pleroma/captcha/captcha.ex index aa41acd1a..cecb5b5a7 100644 --- a/lib/pleroma/captcha/captcha.ex +++ b/lib/pleroma/captcha/captcha.ex @@ -10,7 +10,7 @@ defmodule Pleroma.Captcha do use GenServer @doc false - def start_link() do + def start_link do GenServer.start_link(__MODULE__, [], name: __MODULE__) end @@ -22,7 +22,7 @@ def init(_) do @doc """ Ask the configured captcha service for a new captcha """ - def new() do + def new do GenServer.call(__MODULE__, :new) end diff --git a/lib/pleroma/captcha/kocaptcha.ex b/lib/pleroma/captcha/kocaptcha.ex index 34a611492..61688e778 100644 --- a/lib/pleroma/captcha/kocaptcha.ex +++ b/lib/pleroma/captcha/kocaptcha.ex @@ -7,7 +7,7 @@ defmodule Pleroma.Captcha.Kocaptcha do @behaviour Service @impl Service - def new() do + def new do endpoint = Pleroma.Config.get!([__MODULE__, :endpoint]) case Tesla.get(endpoint <> "/new") do diff --git a/lib/pleroma/clippy.ex b/lib/pleroma/clippy.ex index 4e9bdbe19..1a1606a23 100644 --- a/lib/pleroma/clippy.ex +++ b/lib/pleroma/clippy.ex @@ -7,13 +7,13 @@ defmodule Pleroma.Clippy do # No software is complete until they have a Clippy implementation. # A ballmer peak _may_ be required to change this module. - def tip() do + def tip do tips() |> Enum.random() |> puts() end - def tips() do + def tips do host = Pleroma.Config.get([Pleroma.Web.Endpoint, :url, :host]) [ diff --git a/lib/pleroma/config/deprecation_warnings.ex b/lib/pleroma/config/deprecation_warnings.ex index 7451fd0a7..0345ac19c 100644 --- a/lib/pleroma/config/deprecation_warnings.ex +++ b/lib/pleroma/config/deprecation_warnings.ex @@ -5,7 +5,7 @@ defmodule Pleroma.Config.DeprecationWarnings do require Logger - def check_frontend_config_mechanism() do + def check_frontend_config_mechanism do if Pleroma.Config.get(:fe) do Logger.warn(""" !!!DEPRECATION WARNING!!! diff --git a/lib/pleroma/emoji.ex b/lib/pleroma/emoji.ex index bb3190e08..f3f08cd9d 100644 --- a/lib/pleroma/emoji.ex +++ b/lib/pleroma/emoji.ex @@ -17,13 +17,13 @@ defmodule Pleroma.Emoji do @ets_options [:ordered_set, :protected, :named_table, {:read_concurrency, true}] @doc false - def start_link() do + def start_link do GenServer.start_link(__MODULE__, [], name: __MODULE__) end @doc "Reloads the emojis from disk." @spec reload() :: :ok - def reload() do + def reload do GenServer.call(__MODULE__, :reload) end @@ -38,7 +38,7 @@ def get(name) do @doc "Returns all the emojos!!" @spec get_all() :: [{String.t(), String.t()}, ...] - def get_all() do + def get_all do :ets.tab2list(@ets) end @@ -72,7 +72,7 @@ def code_change(_old_vsn, state, _extra) do {:ok, state} end - defp load() do + defp load do emojis = (load_finmoji(Keyword.get(Application.get_env(:pleroma, :instance), :finmoji_enabled)) ++ load_from_file("config/emoji.txt") ++ diff --git a/lib/pleroma/flake_id.ex b/lib/pleroma/flake_id.ex index 9f098ce33..4259d5718 100644 --- a/lib/pleroma/flake_id.ex +++ b/lib/pleroma/flake_id.ex @@ -85,7 +85,7 @@ def dump(value) do {:ok, FlakeId.from_string(value)} end - def autogenerate(), do: get() + def autogenerate, do: get() # -- GenServer API def start_link do @@ -165,7 +165,7 @@ defp time do 1_000_000_000 * mega_seconds + seconds * 1000 + :erlang.trunc(micro_seconds / 1000) end - defp worker_id() do + defp worker_id do <> = :crypto.strong_rand_bytes(6) worker end diff --git a/lib/pleroma/gopher/server.ex b/lib/pleroma/gopher/server.ex index 5b4e745e9..6baacc566 100644 --- a/lib/pleroma/gopher/server.ex +++ b/lib/pleroma/gopher/server.ex @@ -6,7 +6,7 @@ defmodule Pleroma.Gopher.Server do use GenServer require Logger - def start_link() do + def start_link do config = Pleroma.Config.get(:gopher, []) ip = Keyword.get(config, :ip, {0, 0, 0, 0}) port = Keyword.get(config, :port, 1234) diff --git a/lib/pleroma/html.ex b/lib/pleroma/html.ex index 4dc6998b1..05253157e 100644 --- a/lib/pleroma/html.ex +++ b/lib/pleroma/html.ex @@ -9,7 +9,7 @@ defp get_scrubbers(scrubber) when is_atom(scrubber), do: [scrubber] defp get_scrubbers(scrubbers) when is_list(scrubbers), do: scrubbers defp get_scrubbers(_), do: [Pleroma.HTML.Scrubber.Default] - def get_scrubbers() do + def get_scrubbers do Pleroma.Config.get([:markup, :scrub_policy]) |> get_scrubbers end diff --git a/lib/pleroma/uploaders/swift/keystone.ex b/lib/pleroma/uploaders/swift/keystone.ex index b4f250f9d..3046cdbd2 100644 --- a/lib/pleroma/uploaders/swift/keystone.ex +++ b/lib/pleroma/uploaders/swift/keystone.ex @@ -17,7 +17,7 @@ def process_response_body(body) do |> Poison.decode!() end - def get_token() do + def get_token do settings = Pleroma.Config.get(Pleroma.Uploaders.Swift) username = Keyword.fetch!(settings, :username) password = Keyword.fetch!(settings, :password) diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 762cd8c46..7226e1613 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -1340,7 +1340,7 @@ defp normalize_tags(tags) do |> Enum.map(&String.downcase(&1)) end - defp local_nickname_regex() do + defp local_nickname_regex do if Pleroma.Config.get([:instance, :extended_nickname_format]) do @extended_local_nickname_regex else diff --git a/lib/pleroma/user/welcome_message.ex b/lib/pleroma/user/welcome_message.ex index 8018ac22f..2ba65b75a 100644 --- a/lib/pleroma/user/welcome_message.ex +++ b/lib/pleroma/user/welcome_message.ex @@ -14,7 +14,7 @@ def post_welcome_message_to_user(user) do end end - defp welcome_user() do + defp welcome_user do with nickname when is_binary(nickname) <- Pleroma.Config.get([:instance, :welcome_user_nickname]), %User{local: true} = user <- User.get_cached_by_nickname(nickname) do @@ -24,7 +24,7 @@ defp welcome_user() do end end - defp welcome_message() do + defp welcome_message do Pleroma.Config.get([:instance, :welcome_message]) end end diff --git a/lib/pleroma/web/activity_pub/mrf.ex b/lib/pleroma/web/activity_pub/mrf.ex index eebea207c..1aaa20050 100644 --- a/lib/pleroma/web/activity_pub/mrf.ex +++ b/lib/pleroma/web/activity_pub/mrf.ex @@ -16,7 +16,7 @@ def filter(object) do end) end - def get_policies() do + def get_policies do Application.get_env(:pleroma, :instance, []) |> Keyword.get(:rewrite_policy, []) |> get_policies() diff --git a/lib/pleroma/web/chat_channel.ex b/lib/pleroma/web/chat_channel.ex index efdbba5a1..f63f4bda1 100644 --- a/lib/pleroma/web/chat_channel.ex +++ b/lib/pleroma/web/chat_channel.ex @@ -48,7 +48,7 @@ def add_message(message) do end) end - def messages() do + def messages do Agent.get(__MODULE__, fn state -> state[:messages] |> Enum.reverse() end) end end diff --git a/lib/pleroma/web/federator/federator.ex b/lib/pleroma/web/federator/federator.ex index b5b5049a4..5e690ddb8 100644 --- a/lib/pleroma/web/federator/federator.ex +++ b/lib/pleroma/web/federator/federator.ex @@ -22,7 +22,7 @@ defmodule Pleroma.Web.Federator do @websub Application.get_env(:pleroma, :websub) @ostatus Application.get_env(:pleroma, :ostatus) - def init() do + def init do # 1 minute Process.sleep(1000 * 60) refresh_subscriptions() @@ -58,7 +58,7 @@ def request_subscription(sub) do Jobs.enqueue(:federator_outgoing, __MODULE__, [:request_subscription, sub]) end - def refresh_subscriptions() do + def refresh_subscriptions do Jobs.enqueue(:federator_outgoing, __MODULE__, [:refresh_subscriptions]) end diff --git a/lib/pleroma/web/federator/retry_queue.ex b/lib/pleroma/web/federator/retry_queue.ex index e0ce251d2..71e49494f 100644 --- a/lib/pleroma/web/federator/retry_queue.ex +++ b/lib/pleroma/web/federator/retry_queue.ex @@ -13,7 +13,7 @@ def init(args) do {:ok, %{args | queue_table: queue_table, running_jobs: :sets.new()}} end - def start_link() do + def start_link do enabled = if Mix.env() == :test, do: true, else: Pleroma.Config.get([__MODULE__, :enabled], false) @@ -39,11 +39,11 @@ def enqueue(data, transport, retries \\ 0) do GenServer.cast(__MODULE__, {:maybe_enqueue, data, transport, retries + 1}) end - def get_stats() do + def get_stats do GenServer.call(__MODULE__, :get_stats) end - def reset_stats() do + def reset_stats do GenServer.call(__MODULE__, :reset_stats) end @@ -55,7 +55,7 @@ def get_retry_params(retries) do end end - def get_retry_timer_interval() do + def get_retry_timer_interval do Pleroma.Config.get([:retry_queue, :interval], 1000) end @@ -231,7 +231,7 @@ defp growth_function(retries) do end end - defp maybe_kickoff_timer() do + defp maybe_kickoff_timer do GenServer.cast(__MODULE__, :kickoff_timer) end end diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex index 2ead3eb5e..88e0249a6 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex @@ -1274,7 +1274,7 @@ def login(conn, _) do end end - defp get_or_make_app() do + defp get_or_make_app do find_attrs = %{client_name: @local_mastodon_name, redirect_uris: "."} scopes = ["read", "write", "follow", "push"] diff --git a/lib/pleroma/web/push/push.ex b/lib/pleroma/web/push/push.ex index 951dab535..5259e8e33 100644 --- a/lib/pleroma/web/push/push.ex +++ b/lib/pleroma/web/push/push.ex @@ -13,15 +13,15 @@ defmodule Pleroma.Web.Push do # Client API # ############## - def start_link() do + def start_link do GenServer.start_link(__MODULE__, :ok, name: __MODULE__) end - def vapid_config() do + def vapid_config do Application.get_env(:web_push_encryption, :vapid_details, []) end - def enabled() do + def enabled do case vapid_config() do [] -> false list when is_list(list) -> true diff --git a/test/support/captcha_mock.ex b/test/support/captcha_mock.ex index 9061f2b45..ef4e68bc5 100644 --- a/test/support/captcha_mock.ex +++ b/test/support/captcha_mock.ex @@ -7,7 +7,7 @@ defmodule Pleroma.Captcha.Mock do @behaviour Service @impl Service - def new(), do: %{type: :mock} + def new, do: %{type: :mock} @impl Service def validate(_token, _captcha, _data), do: :ok