Merge branch 'features/add-credo-to-ci' into 'develop'
authorlambda <lain@soykaf.club>
Wed, 13 Mar 2019 09:09:44 +0000 (09:09 +0000)
committerlambda <lain@soykaf.club>
Wed, 13 Mar 2019 09:09:44 +0000 (09:09 +0000)
Add credo to CI

See merge request pleroma/pleroma!902

123 files changed:
.credo.exs
.gitlab-ci.yml
lib/mix/tasks/pleroma/relay.ex
lib/mix/tasks/pleroma/uploads.ex
lib/mix/tasks/pleroma/user.ex
lib/pleroma/PasswordResetToken.ex
lib/pleroma/activity.ex
lib/pleroma/application.ex
lib/pleroma/captcha/captcha.ex
lib/pleroma/captcha/kocaptcha.ex
lib/pleroma/clippy.ex
lib/pleroma/config/deprecation_warnings.ex
lib/pleroma/emoji.ex
lib/pleroma/filter.ex
lib/pleroma/flake_id.ex
lib/pleroma/formatter.ex
lib/pleroma/gopher/server.ex
lib/pleroma/html.ex
lib/pleroma/instances/instance.ex
lib/pleroma/notification.ex
lib/pleroma/object.ex
lib/pleroma/plugs/http_signature.ex
lib/pleroma/plugs/oauth_plug.ex
lib/pleroma/plugs/user_fetcher_plug.ex
lib/pleroma/reverse_proxy.ex
lib/pleroma/stats.ex
lib/pleroma/thread_mute.ex
lib/pleroma/uploaders/s3.ex
lib/pleroma/uploaders/swift/keystone.ex
lib/pleroma/uploaders/uploader.ex
lib/pleroma/user.ex
lib/pleroma/user/welcome_message.ex
lib/pleroma/user_invite_token.ex
lib/pleroma/web/activity_pub/activity_pub.ex
lib/pleroma/web/activity_pub/activity_pub_controller.ex
lib/pleroma/web/activity_pub/mrf.ex
lib/pleroma/web/activity_pub/mrf/keyword_policy.ex
lib/pleroma/web/activity_pub/relay.ex
lib/pleroma/web/activity_pub/transmogrifier.ex
lib/pleroma/web/activity_pub/utils.ex
lib/pleroma/web/activity_pub/views/user_view.ex
lib/pleroma/web/auth/pleroma_authenticator.ex
lib/pleroma/web/channels/user_socket.ex
lib/pleroma/web/chat_channel.ex
lib/pleroma/web/common_api/common_api.ex
lib/pleroma/web/common_api/utils.ex
lib/pleroma/web/controller_helper.ex
lib/pleroma/web/endpoint.ex
lib/pleroma/web/federator/federator.ex
lib/pleroma/web/federator/retry_queue.ex
lib/pleroma/web/mastodon_api/mastodon_api.ex
lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
lib/pleroma/web/mastodon_api/views/admin/account_view.ex
lib/pleroma/web/mastodon_api/websocket_handler.ex
lib/pleroma/web/media_proxy/media_proxy.ex
lib/pleroma/web/metadata/opengraph.ex
lib/pleroma/web/metadata/twitter_card.ex
lib/pleroma/web/metadata/utils.ex
lib/pleroma/web/nodeinfo/nodeinfo.ex [deleted file]
lib/pleroma/web/oauth/authorization.ex
lib/pleroma/web/oauth/oauth_controller.ex
lib/pleroma/web/oauth/token.ex
lib/pleroma/web/ostatus/activity_representer.ex
lib/pleroma/web/ostatus/feed_representer.ex
lib/pleroma/web/ostatus/handlers/delete_handler.ex
lib/pleroma/web/ostatus/handlers/follow_handler.ex
lib/pleroma/web/ostatus/handlers/note_handler.ex
lib/pleroma/web/ostatus/handlers/unfollow_handler.ex
lib/pleroma/web/ostatus/ostatus.ex
lib/pleroma/web/ostatus/ostatus_controller.ex
lib/pleroma/web/push/impl.ex
lib/pleroma/web/push/push.ex
lib/pleroma/web/push/subscription.ex
lib/pleroma/web/rich_media/helpers.ex
lib/pleroma/web/router.ex
lib/pleroma/web/salmon/salmon.ex
lib/pleroma/web/streamer.ex
lib/pleroma/web/twitter_api/controllers/util_controller.ex
lib/pleroma/web/twitter_api/twitter_api.ex
lib/pleroma/web/twitter_api/twitter_api_controller.ex
lib/pleroma/web/twitter_api/views/activity_view.ex
lib/pleroma/web/web_finger/web_finger.ex
lib/pleroma/web/websub/websub.ex
lib/pleroma/web/websub/websub_controller.ex
test/integration/mastodon_websocket_test.exs
test/jobs_test.exs
test/notification_test.exs
test/object_test.exs
test/support/builders/user_builder.ex
test/support/captcha_mock.ex
test/tasks/relay_test.exs
test/user_test.exs
test/web/activity_pub/activity_pub_controller_test.exs
test/web/activity_pub/activity_pub_test.exs
test/web/activity_pub/transmogrifier_test.exs
test/web/activity_pub/utils_test.exs
test/web/activity_pub/views/object_view_test.exs
test/web/activity_pub/visibilty_test.exs
test/web/common_api/common_api_test.exs
test/web/common_api/common_api_utils_test.exs
test/web/federator_test.exs
test/web/instances/instance_test.exs
test/web/instances/instances_test.exs
test/web/mastodon_api/account_view_test.exs
test/web/mastodon_api/mastodon_api_controller_test.exs
test/web/mastodon_api/status_view_test.exs
test/web/oauth/authorization_test.exs
test/web/oauth/token_test.exs
test/web/ostatus/activity_representer_test.exs
test/web/ostatus/feed_representer_test.exs
test/web/ostatus/incoming_documents/delete_handling_test.exs
test/web/ostatus/ostatus_controller_test.exs
test/web/ostatus/ostatus_test.exs
test/web/salmon/salmon_test.exs
test/web/streamer_test.exs
test/web/twitter_api/representers/activity_representer_test.exs
test/web/twitter_api/twitter_api_controller_test.exs
test/web/twitter_api/twitter_api_test.exs
test/web/twitter_api/views/activity_view_test.exs
test/web/twitter_api/views/notification_view_test.exs
test/web/twitter_api/views/user_view_test.exs
test/web/websub/websub_controller_test.exs
test/web/websub/websub_test.exs

index 580cb270539657347a93c6853ab5c01565ef8ac6..46d45d015716267a6ee5c224afe9c2db9d34681d 100644 (file)
@@ -69,8 +69,8 @@
         # You can also customize the exit_status of each check.
         # If you don't want TODO comments to cause `mix credo` to fail, just
         # set this value to 0 (zero).
-        {Credo.Check.Design.TagTODO, exit_status: 2},
-        {Credo.Check.Design.TagFIXME},
+        {Credo.Check.Design.TagTODO, exit_status: 0},
+        {Credo.Check.Design.TagFIXME, exit_status: 0},
 
         {Credo.Check.Readability.FunctionNames},
         {Credo.Check.Readability.LargeNumbers},
@@ -81,7 +81,9 @@
         {Credo.Check.Readability.ParenthesesOnZeroArityDefs},
         {Credo.Check.Readability.ParenthesesInCondition},
         {Credo.Check.Readability.PredicateFunctionNames},
-        {Credo.Check.Readability.PreferImplicitTry},
+        # lanodan: I think PreferImplicitTry should be consistency, and the behaviour seems
+        # inconsistent, see: https://github.com/rrrene/credo/issues/224
+        {Credo.Check.Readability.PreferImplicitTry, false},
         {Credo.Check.Readability.RedundantBlankLines},
         {Credo.Check.Readability.StringSigils},
         {Credo.Check.Readability.TrailingBlankLine},
 
         # Deprecated checks (these will be deleted after a grace period)
         {Credo.Check.Readability.Specs, false},
-        {Credo.Check.Warning.NameRedeclarationByAssignment, false},
-        {Credo.Check.Warning.NameRedeclarationByCase, false},
-        {Credo.Check.Warning.NameRedeclarationByDef, false},
-        {Credo.Check.Warning.NameRedeclarationByFn, false},
 
         # Custom checks can be created using `mix credo.gen.check`.
         #
index 30589c9c575d756bae9357acc262ba7a9268d9f8..d5f2a762a418dcac45d710c1e89f8f2f46b0b15a 100644 (file)
@@ -19,6 +19,7 @@ cache:
 stages:
   - lint
   - test
+  - analysis
 
 before_script:
   - mix local.hex --force
@@ -37,3 +38,8 @@ unit-testing:
   stage: test
   script:
     - mix test --trace --preload-modules
+
+analysis:
+  stage: analysis
+  script:
+    - mix credo --strict --only=warnings,todo,fixme,consistency,readability
index cbe23f82ede0e842a2117fbea3bbd4864b06aeed..fbec473c5d36578fb12f41cbe7e4778d8eaae9e2 100644 (file)
@@ -4,8 +4,8 @@
 
 defmodule Mix.Tasks.Pleroma.Relay do
   use Mix.Task
-  alias Pleroma.Web.ActivityPub.Relay
   alias Mix.Tasks.Pleroma.Common
+  alias Pleroma.Web.ActivityPub.Relay
 
   @shortdoc "Manages remote relays"
   @moduledoc """
index a01e616278ab1f8cd2c5ea6c333698e73e29a5a4..106fcf443fbf6a0e881e2904a350edebdc8da51d 100644 (file)
@@ -4,9 +4,9 @@
 
 defmodule Mix.Tasks.Pleroma.Uploads do
   use Mix.Task
+  alias Mix.Tasks.Pleroma.Common
   alias Pleroma.Upload
   alias Pleroma.Uploaders.Local
-  alias Mix.Tasks.Pleroma.Common
   require Logger
 
   @log_every 50
@@ -20,7 +20,6 @@ defmodule Mix.Tasks.Pleroma.Uploads do
    Options:
    - `--delete` - delete local uploads after migrating them to the target uploader
 
-
    A list of available uploaders can be seen in config.exs
   """
   def run(["migrate_local", target_uploader | args]) do
index 037e4471679d5f6ce780b80437964f49fa38c661..f6cca0d06e31c9bc26efdeef1a6b34a35600e1b5 100644 (file)
@@ -5,9 +5,9 @@
 defmodule Mix.Tasks.Pleroma.User do
   use Mix.Task
   import Ecto.Changeset
+  alias Mix.Tasks.Pleroma.Common
   alias Pleroma.Repo
   alias Pleroma.User
-  alias Mix.Tasks.Pleroma.Common
 
   @shortdoc "Manages Pleroma users"
   @moduledoc """
index 750ddd3c04645e3714face400e0cbbc42bb6ebe8..772c239a1cc3afabed220d60513285219f9f1a3b 100644 (file)
@@ -7,9 +7,9 @@ defmodule Pleroma.PasswordResetToken do
 
   import Ecto.Changeset
 
-  alias Pleroma.User
-  alias Pleroma.Repo
   alias Pleroma.PasswordResetToken
+  alias Pleroma.Repo
+  alias Pleroma.User
 
   schema "password_reset_tokens" do
     belongs_to(:user, User, type: Pleroma.FlakeId)
index 18d5b70deb2425aeb40c384948dc0dfc4d526ad7..79dc26b016de28a9b759626ee847b0936d0a04e0 100644 (file)
@@ -5,9 +5,9 @@
 defmodule Pleroma.Activity do
   use Ecto.Schema
 
-  alias Pleroma.Repo
   alias Pleroma.Activity
   alias Pleroma.Notification
+  alias Pleroma.Repo
 
   import Ecto.Query
 
index d2523c045bec60182164498625ae7dafc9cea6f7..cc81e180565eb84ea0399692b5c48b5a4762c196 100644 (file)
@@ -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
@@ -48,7 +48,7 @@ defmodule Pleroma.Application do
           [
             :user_cache,
             [
-              default_ttl: 25000,
+              default_ttl: 25_000,
               ttl_interval: 1000,
               limit: 2500
             ]
@@ -60,7 +60,7 @@ defmodule Pleroma.Application do
           [
             :object_cache,
             [
-              default_ttl: 25000,
+              default_ttl: 25_000,
               ttl_interval: 1000,
               limit: 2500
             ]
@@ -127,7 +127,7 @@ defmodule Pleroma.Application 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 @@ defmodule Pleroma.Application 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 @@ defmodule Pleroma.Application 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)
index aa41acd1ab21cfdf61cfb4e01675993ea5703299..f105cbb2529bc97a1ad42c6f37de050ddc546044 100644 (file)
@@ -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 @@ defmodule Pleroma.Captcha do
   @doc """
   Ask the configured captcha service for a new captcha
   """
-  def new() do
+  def new do
     GenServer.call(__MODULE__, :new)
   end
 
@@ -73,7 +73,7 @@ defmodule Pleroma.Captcha do
     secret = KeyGenerator.generate(secret_key_base, token <> "_encrypt")
     sign_secret = KeyGenerator.generate(secret_key_base, token <> "_sign")
 
-    # If the time found is less than (current_time - seconds_valid), then the time has already passed.
+    # If the time found is less than (current_time-seconds_valid) then the time has already passed
     # Later we check that the time found is more than the presumed invalidatation time, that means
     # that the data is still valid and the captcha can be checked
     seconds_valid = Pleroma.Config.get!([Pleroma.Captcha, :seconds_valid])
index 34a6114928eb47ae782e546e0d8fad5b7722ad17..61688e778835ad1d2c5c55c98034c8d45a405538 100644 (file)
@@ -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
index 4e9bdbe198b6002d714372eee683e0318c955e7f..bd20952a6952a4c6ee130b620097bd23bb66ae99 100644 (file)
@@ -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])
 
     [
@@ -92,8 +92,8 @@ defmodule Pleroma.Clippy do
 
     # surrond one/five line clippy with blank lines around to not fuck up the layout
     #
-    # yes this fix sucks but it's good enough, have you ever seen a release of windows wihtout some butched
-    # features anyway?
+    # yes this fix sucks but it's good enough, have you ever seen a release of windows
+    # without some butched features anyway?
     lines =
       if length(lines) == 1 or length(lines) == 5 do
         [""] ++ lines ++ [""]
index 7451fd0a7675d8c63b1ab10e398b34462eb7721f..0345ac19cbf31a902ec95704b1eaa2e3b10ee805 100644 (file)
@@ -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!!!
index bb3190e08af3beffd96aebcb1dbe336a04be7281..f3f08cd9dcf15f119a50c25c227289e39a1fc499 100644 (file)
@@ -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 @@ defmodule Pleroma.Emoji 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 @@ defmodule Pleroma.Emoji 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") ++
index bdc34698c13098c09d1cc31906819a6a53ded780..79efc29f0f73803463d8f94ccf79e463a3fbba4a 100644 (file)
@@ -8,8 +8,8 @@ defmodule Pleroma.Filter do
   import Ecto.Changeset
   import Ecto.Query
 
-  alias Pleroma.User
   alias Pleroma.Repo
+  alias Pleroma.User
 
   schema "filters" do
     belongs_to(:user, User, type: Pleroma.FlakeId)
index 9f098ce3378f0ce5deeb2ea2bb03e9804e56f80d..4259d57189bec86d537a345c1b9d3036a86cbd07 100644 (file)
@@ -85,7 +85,7 @@ defmodule Pleroma.FlakeId 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 @@ defmodule Pleroma.FlakeId do
     1_000_000_000 * mega_seconds + seconds * 1000 + :erlang.trunc(micro_seconds / 1000)
   end
 
-  defp worker_id() do
+  defp worker_id do
     <<worker::integer-size(48)>> = :crypto.strong_rand_bytes(6)
     worker
   end
index 048c032ed2a5be1ac4c2489e6a79474b9c2feaa1..1e4ede3f2c8fea4ba484a62ca2194208161cbef8 100644 (file)
@@ -10,6 +10,7 @@ defmodule Pleroma.Formatter do
 
   @markdown_characters_regex ~r/(`|\*|_|{|}|[|]|\(|\)|#|\+|-|\.|!)/
   @link_regex ~r{((?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~%:/?#[\]@!\$&'\(\)\*\+,;=.]+)|[0-9a-z+\-\.]+:[0-9a-z$-_.+!*'(),]+}ui
+  # credo:disable-for-previous-line Credo.Check.Readability.MaxLineLength
 
   @auto_linker_config hashtag: true,
                       hashtag_handler: &Pleroma.Formatter.hashtag_handler/4,
index ba9614029ce510b78c167d12109ecd340e00d88e..6baacc5661ffbb4e3bec9dd4250cd469d1f53416 100644 (file)
@@ -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)
@@ -36,12 +36,12 @@ defmodule Pleroma.Gopher.Server do
 end
 
 defmodule Pleroma.Gopher.Server.ProtocolHandler do
-  alias Pleroma.Web.ActivityPub.ActivityPub
-  alias Pleroma.Web.ActivityPub.Visibility
   alias Pleroma.Activity
   alias Pleroma.HTML
-  alias Pleroma.User
   alias Pleroma.Repo
+  alias Pleroma.User
+  alias Pleroma.Web.ActivityPub.ActivityPub
+  alias Pleroma.Web.ActivityPub.Visibility
 
   def start_link(ref, socket, transport, opts) do
     pid = spawn_link(__MODULE__, :init, [ref, socket, transport, opts])
index 4dc6998b12e770170115392d19fc095ded160767..05253157e6e027e7ee12ae4d19d530fd80c2190a 100644 (file)
@@ -9,7 +9,7 @@ defmodule Pleroma.HTML do
   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
index 48bc939dd0958aa5748d46cb09a7d5403a18c87e..e92006151b218dd3333e50c88ce6ffa6a7d9631a 100644 (file)
@@ -2,8 +2,8 @@ defmodule Pleroma.Instances.Instance do
   @moduledoc "Instance."
 
   alias Pleroma.Instances
-  alias Pleroma.Repo
   alias Pleroma.Instances.Instance
+  alias Pleroma.Repo
 
   use Ecto.Schema
 
index c88512567bada8f768b6000bc18575afe3110d09..fe8181d8b57498bd35fc2039159d118b21af1338 100644 (file)
@@ -5,12 +5,12 @@
 defmodule Pleroma.Notification do
   use Ecto.Schema
 
-  alias Pleroma.User
   alias Pleroma.Activity
   alias Pleroma.Notification
   alias Pleroma.Repo
-  alias Pleroma.Web.CommonAPI.Utils
+  alias Pleroma.User
   alias Pleroma.Web.CommonAPI
+  alias Pleroma.Web.CommonAPI.Utils
 
   import Ecto.Query
 
index 7510a09bbe27777b9729c3bd3ba7634278bba0c0..58e46ef1d4dcb1771ca1b377f1360abfae7bf2d4 100644 (file)
@@ -5,11 +5,11 @@
 defmodule Pleroma.Object do
   use Ecto.Schema
 
-  alias Pleroma.Repo
-  alias Pleroma.Object
-  alias Pleroma.User
   alias Pleroma.Activity
+  alias Pleroma.Object
   alias Pleroma.ObjectTombstone
+  alias Pleroma.Repo
+  alias Pleroma.User
 
   import Ecto.Query
   import Ecto.Changeset
index 51bec910e275ad6bf05d930336c97a53bbc169e3..21c1957135c0e5542847e7e2e4aa58682e5972b2 100644 (file)
@@ -3,8 +3,8 @@
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Web.Plugs.HTTPSignaturePlug do
-  alias Pleroma.Web.HTTPSignatures
   alias Pleroma.Web.ActivityPub.Utils
+  alias Pleroma.Web.HTTPSignatures
   import Plug.Conn
   require Logger
 
index 22f0406f4637cfc486a1a86155903667b8b7729c..5888d596aaaf4ae89df271be0166eabb13b75152 100644 (file)
@@ -6,8 +6,8 @@ defmodule Pleroma.Plugs.OAuthPlug do
   import Plug.Conn
   import Ecto.Query
 
-  alias Pleroma.User
   alias Pleroma.Repo
+  alias Pleroma.User
   alias Pleroma.Web.OAuth.Token
 
   @realm_reg Regex.compile!("Bearer\:?\s+(.*)$", "i")
@@ -38,6 +38,7 @@ defmodule Pleroma.Plugs.OAuthPlug do
         preload: [user: user]
       )
 
+    # credo:disable-for-next-line Credo.Check.Readability.MaxLineLength
     with %Token{user: %{info: %{deactivated: false} = _} = user} = token_record <- Repo.one(query) do
       {:ok, user, token_record}
     end
index 7ed4602bbd2a5c43e4a96aba0b975657f05a4958..5a77f683361321be000612417268d212f99ac0e6 100644 (file)
@@ -3,8 +3,8 @@
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Plugs.UserFetcherPlug do
-  alias Pleroma.User
   alias Pleroma.Repo
+  alias Pleroma.User
 
   import Plug.Conn
 
index a25b5ea4e16f0af9c804d65a53a4fd4a7afd3fd4..6298b92f4e4c12ceb4b17feebfde431ee5a747e1 100644 (file)
@@ -3,10 +3,12 @@
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.ReverseProxy do
-  @keep_req_headers ~w(accept user-agent accept-encoding cache-control if-modified-since if-unmodified-since if-none-match if-range range)
+  @keep_req_headers ~w(accept user-agent accept-encoding cache-control if-modified-since) ++
+                      ~w(if-unmodified-since if-none-match if-range range)
   @resp_cache_headers ~w(etag date last-modified cache-control)
   @keep_resp_headers @resp_cache_headers ++
-                       ~w(content-type content-disposition content-encoding content-range accept-ranges vary)
+                       ~w(content-type content-disposition content-encoding content-range) ++
+                       ~w(accept-ranges vary)
   @default_cache_control_header "public, max-age=1209600"
   @valid_resp_codes [200, 206, 304]
   @max_read_duration :timer.seconds(30)
@@ -282,8 +284,8 @@ defmodule Pleroma.ReverseProxy do
         headers
 
       has_cache? ->
-        # There's caching header present but no cache-control -- we need to explicitely override it to public
-        # as Plug defaults to "max-age=0, private, must-revalidate"
+        # There's caching header present but no cache-control -- we need to explicitely override it
+        # to public as Plug defaults to "max-age=0, private, must-revalidate"
         List.keystore(headers, "cache-control", 0, {"cache-control", "public"})
 
       true ->
index fe0ce9051a9e3359849cb6b63fbbd808aa0ab434..2e7d747df9c2a6b9a978a005937abbef1c9bc454 100644 (file)
@@ -4,8 +4,8 @@
 
 defmodule Pleroma.Stats do
   import Ecto.Query
-  alias Pleroma.User
   alias Pleroma.Repo
+  alias Pleroma.User
 
   def start_link do
     agent = Agent.start_link(fn -> {[], %{}} end, name: __MODULE__)
index 0b577113d744b5b300c8446b98c463f685dae57b..10d31679daa17d77ad9c086f5cb8deb6a08d8582 100644 (file)
@@ -4,7 +4,11 @@
 
 defmodule Pleroma.ThreadMute do
   use Ecto.Schema
-  alias Pleroma.{Repo, User, ThreadMute}
+
+  alias Pleroma.Repo
+  alias Pleroma.ThreadMute
+  alias Pleroma.User
+
   require Ecto.Query
 
   schema "thread_mutes" do
index 0038ba01fdc0104bf3f06df637be60ed985ddc12..e7de3f3e0de84da366987a3b0a89ca9429080c20 100644 (file)
@@ -6,7 +6,8 @@ defmodule Pleroma.Uploaders.S3 do
   @behaviour Pleroma.Uploaders.Uploader
   require Logger
 
-  # The file name is re-encoded with S3's constraints here to comply with previous links with less strict filenames
+  # The file name is re-encoded with S3's constraints here to comply with previous
+  # links with less strict filenames
   def get_file(file) do
     config = Pleroma.Config.get([__MODULE__])
     bucket = Keyword.fetch!(config, :bucket)
index b4f250f9d99fbabdfdba2a7f4bf2bf0041882247..3046cdbd2e374f231ba7683f190882cc095767f8 100644 (file)
@@ -17,7 +17,7 @@ defmodule Pleroma.Uploaders.Swift.Keystone 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)
index ce83cbbbc76584afdc0dc45de40e64b33f0cae2f..bf15389fcde3c46ed9ecf9f8a1c5f3ebcd514813 100644 (file)
@@ -29,7 +29,6 @@ defmodule Pleroma.Uploaders.Uploader do
   * `{:error, String.t}` error information if the file failed to be saved to the backend.
   * `:wait_callback` will wait for an http post request at `/api/pleroma/upload_callback/:upload_path` and call the uploader's `http_callback/3` method.
 
-
   """
   @type file_spec :: {:file | :url, String.t()}
   @callback put_file(Pleroma.Upload.t()) ::
index f49ede149eec5a1e5fbe085d1a10877d0ff24654..1ce9882f63b6125c82c947dd16a47f3e55342f34 100644 (file)
@@ -8,21 +8,21 @@ defmodule Pleroma.User do
   import Ecto.Changeset
   import Ecto.Query
 
+  alias Comeonin.Pbkdf2
+  alias Pleroma.Activity
+  alias Pleroma.Formatter
+  alias Pleroma.Notification
+  alias Pleroma.Object
   alias Pleroma.Repo
   alias Pleroma.User
-  alias Pleroma.Object
   alias Pleroma.Web
-  alias Pleroma.Activity
-  alias Pleroma.Notification
-  alias Comeonin.Pbkdf2
-  alias Pleroma.Formatter
+  alias Pleroma.Web.ActivityPub.ActivityPub
+  alias Pleroma.Web.ActivityPub.Utils
   alias Pleroma.Web.CommonAPI.Utils, as: CommonUtils
-  alias Pleroma.Web.OStatus
-  alias Pleroma.Web.Websub
   alias Pleroma.Web.OAuth
-  alias Pleroma.Web.ActivityPub.Utils
-  alias Pleroma.Web.ActivityPub.ActivityPub
+  alias Pleroma.Web.OStatus
   alias Pleroma.Web.RelMe
+  alias Pleroma.Web.Websub
 
   require Logger
 
@@ -30,6 +30,7 @@ defmodule Pleroma.User do
 
   @primary_key {:id, Pleroma.FlakeId, autogenerate: true}
 
+  # credo:disable-for-next-line Credo.Check.Readability.MaxLineLength
   @email_regex ~r/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/
 
   @strict_local_nickname_regex ~r/^[a-zA-Z\d]+$/
@@ -285,7 +286,7 @@ defmodule Pleroma.User do
   def needs_update?(%User{local: false, last_refreshed_at: nil}), do: true
 
   def needs_update?(%User{local: false} = user) do
-    NaiveDateTime.diff(NaiveDateTime.utc_now(), user.last_refreshed_at) >= 86400
+    NaiveDateTime.diff(NaiveDateTime.utc_now(), user.last_refreshed_at) >= 86_400
   end
 
   def needs_update?(_), do: true
@@ -435,7 +436,8 @@ defmodule Pleroma.User do
     Repo.get_by(User, ap_id: ap_id)
   end
 
-  # This is mostly an SPC migration fix. This guesses the user nickname (by taking the last part of the ap_id and the domain) and tries to get that user
+  # This is mostly an SPC migration fix. This guesses the user nickname by taking the last part
+  # of the ap_id and the domain and tries to get that user
   def get_by_guessed_nickname(ap_id) do
     domain = URI.parse(ap_id).host
     name = List.last(String.split(ap_id, "/"))
@@ -1340,7 +1342,7 @@ defmodule Pleroma.User 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
index 8018ac22f967662cd7900b69e5e985c04f4f7212..2ba65b75acad271254baa5bc37e2e6061f9d7548 100644 (file)
@@ -14,7 +14,7 @@ defmodule Pleroma.User.WelcomeMessage 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 @@ defmodule Pleroma.User.WelcomeMessage do
     end
   end
 
-  defp welcome_message() do
+  defp welcome_message do
     Pleroma.Config.get([:instance, :welcome_message])
   end
 end
index 5a448114c4df20c9dc55d8780a6969888df352b7..9c5579934dddf6e68525992d1fcc7458e7da3997 100644 (file)
@@ -7,8 +7,8 @@ defmodule Pleroma.UserInviteToken do
 
   import Ecto.Changeset
 
-  alias Pleroma.UserInviteToken
   alias Pleroma.Repo
+  alias Pleroma.UserInviteToken
 
   schema "user_invite_tokens" do
     field(:token, :string)
index 2f11f8984a1063db622dd96ace6a9dbb75576459..d5b03cd2488d47be265fb9474c7418426120a20f 100644 (file)
@@ -4,17 +4,17 @@
 
 defmodule Pleroma.Web.ActivityPub.ActivityPub do
   alias Pleroma.Activity
-  alias Pleroma.Repo
+  alias Pleroma.Instances
+  alias Pleroma.Notification
   alias Pleroma.Object
+  alias Pleroma.Repo
   alias Pleroma.Upload
   alias Pleroma.User
-  alias Pleroma.Notification
-  alias Pleroma.Instances
-  alias Pleroma.Web.ActivityPub.Transmogrifier
   alias Pleroma.Web.ActivityPub.MRF
-  alias Pleroma.Web.WebFinger
+  alias Pleroma.Web.ActivityPub.Transmogrifier
   alias Pleroma.Web.Federator
   alias Pleroma.Web.OStatus
+  alias Pleroma.Web.WebFinger
 
   import Ecto.Query
   import Pleroma.Web.ActivityPub.Utils
@@ -170,7 +170,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
              additional
            ),
          {:ok, activity} <- insert(create_data, local),
-         # Changing note count prior to enqueuing federation task in order to avoid race conditions on updating user.info
+         # Changing note count prior to enqueuing federation task in order to avoid
+         # race conditions on updating user.info
          {:ok, _actor} <- increase_note_count_if_public(actor, activity),
          :ok <- maybe_federate(activity) do
       {:ok, activity}
@@ -320,7 +321,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
            "deleted_activity_id" => activity && activity.id
          },
          {:ok, activity} <- insert(data, local),
-         # Changing note count prior to enqueuing federation task in order to avoid race conditions on updating user.info
+         # Changing note count prior to enqueuing federation task in order to avoid
+         # race conditions on updating user.info
          {:ok, _actor} <- decrease_note_count_if_public(user, object),
          :ok <- maybe_federate(activity) do
       {:ok, activity}
@@ -502,7 +504,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
        when is_list(tag_reject) and tag_reject != [] do
     from(
       activity in query,
-      where: fragment("(not (? #> '{\"object\",\"tag\"}') \\?| ?)", activity.data, ^tag_reject)
+      where: fragment(~s(\(not \(? #> '{"object","tag"}'\) \\?| ?\)), activity.data, ^tag_reject)
     )
   end
 
@@ -512,7 +514,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
        when is_list(tag_all) and tag_all != [] do
     from(
       activity in query,
-      where: fragment("(? #> '{\"object\",\"tag\"}') \\?& ?", activity.data, ^tag_all)
+      where: fragment(~s(\(? #> '{"object","tag"}'\) \\?& ?), activity.data, ^tag_all)
     )
   end
 
@@ -521,14 +523,14 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
   defp restrict_tag(query, %{"tag" => tag}) when is_list(tag) do
     from(
       activity in query,
-      where: fragment("(? #> '{\"object\",\"tag\"}') \\?| ?", activity.data, ^tag)
+      where: fragment(~s(\(? #> '{"object","tag"}'\) \\?| ?), activity.data, ^tag)
     )
   end
 
   defp restrict_tag(query, %{"tag" => tag}) when is_binary(tag) do
     from(
       activity in query,
-      where: fragment("? <@ (? #> '{\"object\",\"tag\"}')", ^tag, activity.data)
+      where: fragment(~s(? <@ (? #> '{"object","tag"}'\)), ^tag, activity.data)
     )
   end
 
@@ -601,7 +603,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
   defp restrict_favorited_by(query, %{"favorited_by" => ap_id}) do
     from(
       activity in query,
-      where: fragment("? <@ (? #> '{\"object\",\"likes\"}')", ^ap_id, activity.data)
+      where: fragment(~s(? <@ (? #> '{"object","likes"}'\)), ^ap_id, activity.data)
     )
   end
 
@@ -610,7 +612,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
   defp restrict_media(query, %{"only_media" => val}) when val == "true" or val == "1" do
     from(
       activity in query,
-      where: fragment("not (? #> '{\"object\",\"attachment\"}' = ?)", activity.data, ^[])
+      where: fragment(~s(not (? #> '{"object","attachment"}' = ?\)), activity.data, ^[])
     )
   end
 
index ff924a5362d6093113cf229bbb2e106bb4e57201..7091d6927fa3373c3f72a7924ef3825473939fd8 100644 (file)
@@ -6,15 +6,15 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do
   use Pleroma.Web, :controller
 
   alias Pleroma.Activity
-  alias Pleroma.User
   alias Pleroma.Object
-  alias Pleroma.Web.ActivityPub.ObjectView
-  alias Pleroma.Web.ActivityPub.UserView
+  alias Pleroma.User
   alias Pleroma.Web.ActivityPub.ActivityPub
-  alias Pleroma.Web.ActivityPub.Visibility
+  alias Pleroma.Web.ActivityPub.ObjectView
   alias Pleroma.Web.ActivityPub.Relay
   alias Pleroma.Web.ActivityPub.Transmogrifier
+  alias Pleroma.Web.ActivityPub.UserView
   alias Pleroma.Web.ActivityPub.Utils
+  alias Pleroma.Web.ActivityPub.Visibility
   alias Pleroma.Web.Federator
 
   require Logger
index eebea207c14d05c420f2d434454bfe0ab0633ee3..1aaa2005051857a1584c755d8ebb1b39fc59949c 100644 (file)
@@ -16,7 +16,7 @@ defmodule Pleroma.Web.ActivityPub.MRF do
     end)
   end
 
-  def get_policies() do
+  def get_policies do
     Application.get_env(:pleroma, :instance, [])
     |> Keyword.get(:rewrite_policy, [])
     |> get_policies()
index 5fdc0341452107e9826c0e1aa5a480471daa5d46..25d5f9cd36f628b2d20c43144c636029c810ac6e 100644 (file)
@@ -45,13 +45,14 @@ defmodule Pleroma.Web.ActivityPub.MRF.KeywordPolicy do
 
   defp check_replace(%{"object" => %{"content" => content, "summary" => summary}} = message) do
     {content, summary} =
-      Enum.reduce(Pleroma.Config.get([:mrf_keyword, :replace]), {content, summary}, fn {pattern,
-                                                                                        replacement},
-                                                                                       {content_acc,
-                                                                                        summary_acc} ->
-        {String.replace(content_acc, pattern, replacement),
-         String.replace(summary_acc, pattern, replacement)}
-      end)
+      Enum.reduce(
+        Pleroma.Config.get([:mrf_keyword, :replace]),
+        {content, summary},
+        fn {pattern, replacement}, {content_acc, summary_acc} ->
+          {String.replace(content_acc, pattern, replacement),
+           String.replace(summary_acc, pattern, replacement)}
+        end
+      )
 
     {:ok,
      message
index c496063ea1cd89ba95cf92a519d297f1144f5a10..01fef71b9c2db04df59219eb647772f53dbf07d9 100644 (file)
@@ -3,9 +3,9 @@
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Web.ActivityPub.Relay do
-  alias Pleroma.User
-  alias Pleroma.Object
   alias Pleroma.Activity
+  alias Pleroma.Object
+  alias Pleroma.User
   alias Pleroma.Web.ActivityPub.ActivityPub
   require Logger
 
index 27d223a3e3bcb78bef46b8ae9b548c642192bf16..1247e4b6164f45dafb6f91a2573fa55745e7af17 100644 (file)
@@ -7,9 +7,9 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
   A module to handle coding from internal to wire ActivityPub and back.
   """
   alias Pleroma.Activity
-  alias Pleroma.User
   alias Pleroma.Object
   alias Pleroma.Repo
+  alias Pleroma.User
   alias Pleroma.Web.ActivityPub.ActivityPub
   alias Pleroma.Web.ActivityPub.Utils
   alias Pleroma.Web.ActivityPub.Visibility
@@ -650,10 +650,10 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
     if object = Object.normalize(id), do: {:ok, object}, else: nil
   end
 
-  def set_reply_to_uri(%{"inReplyTo" => inReplyTo} = object) when is_binary(inReplyTo) do
-    with false <- String.starts_with?(inReplyTo, "http"),
-         {:ok, %{data: replied_to_object}} <- get_obj_helper(inReplyTo) do
-      Map.put(object, "inReplyTo", replied_to_object["external_url"] || inReplyTo)
+  def set_reply_to_uri(%{"inReplyTo" => in_reply_to} = object) when is_binary(in_reply_to) do
+    with false <- String.starts_with?(in_reply_to, "http"),
+         {:ok, %{data: replied_to_object}} <- get_obj_helper(in_reply_to) do
+      Map.put(object, "inReplyTo", replied_to_object["external_url"] || in_reply_to)
     else
       _e -> object
     end
@@ -830,10 +830,10 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
   end
 
   def add_attributed_to(object) do
-    attributedTo = object["attributedTo"] || object["actor"]
+    attributed_to = object["attributedTo"] || object["actor"]
 
     object
-    |> Map.put("attributedTo", attributedTo)
+    |> Map.put("attributedTo", attributed_to)
   end
 
   def add_likes(%{"id" => id, "like_count" => likes} = object) do
index 629c39315ec5095690bf634f224137aeeb50555f..182f9cacbdbc8769bed2cacd36a3d6e605541c28 100644 (file)
@@ -3,17 +3,17 @@
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Web.ActivityPub.Utils do
+  alias Ecto.Changeset
+  alias Ecto.UUID
+  alias Pleroma.Activity
+  alias Pleroma.Notification
+  alias Pleroma.Object
   alias Pleroma.Repo
+  alias Pleroma.User
   alias Pleroma.Web
-  alias Pleroma.Object
-  alias Pleroma.Activity
   alias Pleroma.Web.ActivityPub.Visibility
-  alias Pleroma.User
-  alias Pleroma.Notification
-  alias Pleroma.Web.Router.Helpers
   alias Pleroma.Web.Endpoint
-  alias Ecto.Changeset
-  alias Ecto.UUID
+  alias Pleroma.Web.Router.Helpers
 
   import Ecto.Query
 
index 415cbd47a5ef98713034623b5ae7c4d5231b859c..3d00dcbf29ea2271d8375de139ead7fb8e8d5d3e 100644 (file)
@@ -5,15 +5,15 @@
 defmodule Pleroma.Web.ActivityPub.UserView do
   use Pleroma.Web, :view
 
-  alias Pleroma.Web.WebFinger
-  alias Pleroma.Web.Salmon
-  alias Pleroma.User
   alias Pleroma.Repo
+  alias Pleroma.User
   alias Pleroma.Web.ActivityPub.ActivityPub
   alias Pleroma.Web.ActivityPub.Transmogrifier
   alias Pleroma.Web.ActivityPub.Utils
-  alias Pleroma.Web.Router.Helpers
   alias Pleroma.Web.Endpoint
+  alias Pleroma.Web.Router.Helpers
+  alias Pleroma.Web.Salmon
+  alias Pleroma.Web.WebFinger
 
   import Ecto.Query
 
index 3cc19af016446c08c9fc73a29751db746e226fae..333446befc681c7e8d9df2b6a95f66dd3eaaa151 100644 (file)
@@ -3,8 +3,8 @@
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Web.Auth.PleromaAuthenticator do
-  alias Pleroma.User
   alias Comeonin.Pbkdf2
+  alias Pleroma.User
 
   @behaviour Pleroma.Web.Auth.Authenticator
 
index aed8475fd88d34f887b609dd4f1977623584bfba..3a700fa3bea0d2cd7643c58b505694882e4e75c0 100644 (file)
@@ -23,7 +23,7 @@ defmodule Pleroma.Web.UserSocket do
   # performing token verification on connect.
   def connect(%{"token" => token}, socket) do
     with true <- Pleroma.Config.get([:chat, :enabled]),
-         {:ok, user_id} <- Phoenix.Token.verify(socket, "user socket", token, max_age: 84600),
+         {:ok, user_id} <- Phoenix.Token.verify(socket, "user socket", token, max_age: 84_600),
          %User{} = user <- Pleroma.Repo.get(User, user_id) do
       {:ok, assign(socket, :user_name, user.nickname)}
     else
index fe63ede664cc2b67bf019e4bce15de718f5682ec..f63f4bda1d1f5b92333bce15b5817530ed2f931a 100644 (file)
@@ -4,8 +4,8 @@
 
 defmodule Pleroma.Web.ChatChannel do
   use Phoenix.Channel
-  alias Pleroma.Web.ChatChannel.ChatChannelState
   alias Pleroma.User
+  alias Pleroma.Web.ChatChannel.ChatChannelState
 
   def join("chat:public", _message, socket) do
     send(self(), :after_join)
@@ -48,7 +48,7 @@ defmodule Pleroma.Web.ChatChannel.ChatChannelState do
     end)
   end
 
-  def messages() do
+  def messages do
     Agent.get(__MODULE__, fn state -> state[:messages] |> Enum.reverse() end)
   end
 end
index 07bd6548a8e6c96f3bd180c4a430986628cbd692..12b3d308ce31a3a33d0eaeba77b0a894c2cc7329 100644 (file)
@@ -3,14 +3,14 @@
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Web.CommonAPI do
-  alias Pleroma.User
-  alias Pleroma.Repo
   alias Pleroma.Activity
+  alias Pleroma.Formatter
   alias Pleroma.Object
+  alias Pleroma.Repo
   alias Pleroma.ThreadMute
+  alias Pleroma.User
   alias Pleroma.Web.ActivityPub.ActivityPub
   alias Pleroma.Web.ActivityPub.Utils
-  alias Pleroma.Formatter
 
   import Pleroma.Web.CommonAPI.Utils
 
@@ -88,8 +88,8 @@ defmodule Pleroma.Web.CommonAPI do
       nil ->
         "public"
 
-      inReplyTo ->
-        Pleroma.Web.MastodonAPI.StatusView.get_visibility(inReplyTo.data["object"])
+      in_reply_to ->
+        Pleroma.Web.MastodonAPI.StatusView.get_visibility(in_reply_to.data["object"])
     end
   end
 
@@ -101,15 +101,15 @@ defmodule Pleroma.Web.CommonAPI do
 
     with status <- String.trim(status),
          attachments <- attachments_from_ids(data),
-         inReplyTo <- get_replied_to_activity(data["in_reply_to_status_id"]),
+         in_reply_to <- get_replied_to_activity(data["in_reply_to_status_id"]),
          {content_html, mentions, tags} <-
            make_content_html(
              status,
              attachments,
              data
            ),
-         {to, cc} <- to_for_user_and_mentions(user, mentions, inReplyTo, visibility),
-         context <- make_context(inReplyTo),
+         {to, cc} <- to_for_user_and_mentions(user, mentions, in_reply_to, visibility),
+         context <- make_context(in_reply_to),
          cw <- data["spoiler_text"],
          full_payload <- String.trim(status <> (data["spoiler_text"] || "")),
          length when length in 1..limit <- String.length(full_payload),
@@ -120,7 +120,7 @@ defmodule Pleroma.Web.CommonAPI do
              context,
              content_html,
              attachments,
-             inReplyTo,
+             in_reply_to,
              tags,
              cw,
              cc
index e4b9102c50b968dc0751c70975559183af5dbb47..b7513ef284991428881ec2297cfb8cc74466623e 100644 (file)
@@ -6,14 +6,14 @@ defmodule Pleroma.Web.CommonAPI.Utils do
   alias Calendar.Strftime
   alias Comeonin.Pbkdf2
   alias Pleroma.Activity
+  alias Pleroma.Config
   alias Pleroma.Formatter
   alias Pleroma.Object
   alias Pleroma.Repo
   alias Pleroma.User
-  alias Pleroma.Config
+  alias Pleroma.Web.ActivityPub.Utils
   alias Pleroma.Web.Endpoint
   alias Pleroma.Web.MediaProxy
-  alias Pleroma.Web.ActivityPub.Utils
 
   # This is a hack for twidere.
   def get_by_id_or_ap_id(id) do
index 5915ea40e76730ceaa8bb233b29ced4939312fca..4d6192db03edb5f63eb8bbbc66078c0cb20d5792 100644 (file)
@@ -6,7 +6,8 @@ defmodule Pleroma.Web.ControllerHelper do
   use Pleroma.Web, :controller
 
   def oauth_scopes(params, default) do
-    # Note: `scopes` is used by Mastodon â€” supporting it but sticking to OAuth's standard `scope` wherever we control it
+    # Note: `scopes` is used by Mastodon â€” supporting it but sticking to
+    # OAuth's standard `scope` wherever we control it
     Pleroma.Web.OAuth.parse_scopes(params["scope"] || params["scopes"], default)
   end
 
index 3eed047ca9503352b7d214867e0669417f62aceb..697b1bc3a7357ecccbf48879aedb760b64473ac4 100644 (file)
@@ -26,6 +26,7 @@ defmodule Pleroma.Web.Endpoint do
     from: :pleroma,
     only:
       ~w(index.html static finmoji emoji packs sounds images instance sw.js sw-pleroma.js favicon.png schemas doc)
+    # credo:disable-for-previous-line Credo.Check.Readability.MaxLineLength
   )
 
   # Code reloading can be explicitly enabled under the
index fbfe97dbc7a79640071cfd2de5e6496b6fe4c762..5e690ddb84446e08bb64c99e95aa2660bbaf9740 100644 (file)
@@ -4,27 +4,27 @@
 
 defmodule Pleroma.Web.Federator do
   alias Pleroma.Activity
+  alias Pleroma.Jobs
   alias Pleroma.User
-  alias Pleroma.Web.WebFinger
-  alias Pleroma.Web.Websub
-  alias Pleroma.Web.Salmon
   alias Pleroma.Web.ActivityPub.ActivityPub
-  alias Pleroma.Web.ActivityPub.Visibility
   alias Pleroma.Web.ActivityPub.Relay
   alias Pleroma.Web.ActivityPub.Transmogrifier
   alias Pleroma.Web.ActivityPub.Utils
+  alias Pleroma.Web.ActivityPub.Visibility
   alias Pleroma.Web.Federator.RetryQueue
   alias Pleroma.Web.OStatus
-  alias Pleroma.Jobs
+  alias Pleroma.Web.Salmon
+  alias Pleroma.Web.WebFinger
+  alias Pleroma.Web.Websub
 
   require Logger
 
   @websub Application.get_env(:pleroma, :websub)
   @ostatus Application.get_env(:pleroma, :ostatus)
 
-  def init() do
+  def init do
     # 1 minute
-    Process.sleep(1000 * 60 * 1)
+    Process.sleep(1000 * 60)
     refresh_subscriptions()
   end
 
@@ -58,7 +58,7 @@ defmodule Pleroma.Web.Federator 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
 
index e0ce251d201f813b2d22529b4f8962698734777c..71e49494fd5a381616b6ed7a7eb324cba0112558 100644 (file)
@@ -13,7 +13,7 @@ defmodule Pleroma.Web.Federator.RetryQueue 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 @@ defmodule Pleroma.Web.Federator.RetryQueue 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 @@ defmodule Pleroma.Web.Federator.RetryQueue 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 @@ defmodule Pleroma.Web.Federator.RetryQueue do
     end
   end
 
-  defp maybe_kickoff_timer() do
+  defp maybe_kickoff_timer do
     GenServer.cast(__MODULE__, :kickoff_timer)
   end
 end
index c952c5806ebfed326dbcc9dacd63154705935b16..54cb6c97a3bbb7374360ac63766a4d048e875a1b 100644 (file)
@@ -2,8 +2,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPI do
   import Ecto.Query
   import Ecto.Changeset
 
-  alias Pleroma.User
   alias Pleroma.Repo
+  alias Pleroma.User
 
   @default_limit 20
 
index a97bc75694fdfdcc75a7a59d9c5f7361219d0720..88e0249a60672bdd0613d85ff51c3dc21559b816 100644 (file)
@@ -4,6 +4,7 @@
 
 defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
   use Pleroma.Web, :controller
+
   alias Pleroma.Activity
   alias Pleroma.Config
   alias Pleroma.Filter
@@ -13,19 +14,18 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
   alias Pleroma.Stats
   alias Pleroma.User
   alias Pleroma.Web
+  alias Pleroma.Web.ActivityPub.ActivityPub
+  alias Pleroma.Web.ActivityPub.Utils
+  alias Pleroma.Web.ActivityPub.Visibility
   alias Pleroma.Web.CommonAPI
-  alias Pleroma.Web.MediaProxy
-
   alias Pleroma.Web.MastodonAPI.AccountView
   alias Pleroma.Web.MastodonAPI.FilterView
   alias Pleroma.Web.MastodonAPI.ListView
+  alias Pleroma.Web.MastodonAPI.MastodonAPI
   alias Pleroma.Web.MastodonAPI.MastodonView
-  alias Pleroma.Web.MastodonAPI.StatusView
   alias Pleroma.Web.MastodonAPI.ReportView
-  alias Pleroma.Web.MastodonAPI.MastodonAPI
-  alias Pleroma.Web.ActivityPub.ActivityPub
-  alias Pleroma.Web.ActivityPub.Utils
-  alias Pleroma.Web.ActivityPub.Visibility
+  alias Pleroma.Web.MastodonAPI.StatusView
+  alias Pleroma.Web.MediaProxy
   alias Pleroma.Web.OAuth.App
   alias Pleroma.Web.OAuth.Authorization
   alias Pleroma.Web.OAuth.Token
@@ -1274,7 +1274,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController 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"]
 
index 66ad20ec42de7e470b3cef619c7ead8ef00551bb..5ce0171249cae3158ee28b304f2a42a67add8535 100644 (file)
@@ -5,8 +5,8 @@
 defmodule Pleroma.Web.MastodonAPI.Admin.AccountView do
   use Pleroma.Web, :view
 
-  alias Pleroma.Web.MastodonAPI.Admin.AccountView
   alias Pleroma.User.Info
+  alias Pleroma.Web.MastodonAPI.Admin.AccountView
 
   def render("index.json", %{users: users, count: count, page_size: page_size}) do
     %{
index 8efe2efd59f4b2863ac85702888f369b3d6d5e8f..9b262f4616992709805bf1d4689c257f7cf95101 100644 (file)
@@ -5,9 +5,9 @@
 defmodule Pleroma.Web.MastodonAPI.WebsocketHandler do
   require Logger
 
-  alias Pleroma.Web.OAuth.Token
   alias Pleroma.Repo
   alias Pleroma.User
+  alias Pleroma.Web.OAuth.Token
 
   @behaviour :cowboy_websocket
 
index 39a725a6941c86c61ae69d18657772ad7fb61c43..3bd2affe9e63733727a64ca1839eca27c15a924b 100644 (file)
@@ -19,7 +19,8 @@ defmodule Pleroma.Web.MediaProxy do
     else
       secret = Application.get_env(:pleroma, Pleroma.Web.Endpoint)[:secret_key_base]
 
-      # Must preserve `%2F` for compatibility with S3 (https://git.pleroma.social/pleroma/pleroma/issues/580)
+      # Must preserve `%2F` for compatibility with S3
+      # https://git.pleroma.social/pleroma/pleroma/issues/580
       replacement = get_replacement(url, ":2F:")
 
       # The URL is url-decoded and encoded again to ensure it is correctly encoded and not twice.
index cafb8134b06b8405ba0c2d98800136431b5f4cf1..357b80a2d50e7959bd8d5b8dfe36d2468f25def9 100644 (file)
@@ -88,7 +88,7 @@ defmodule Pleroma.Web.Metadata.Providers.OpenGraph do
 
           # TODO: Add additional properties to objects when we have the data available.
           # Also, Whatsapp only wants JPEG or PNGs. It seems that if we add a second og:image
-          # object when a Video or GIF is attached it will display that in the Whatsapp Rich Preview.
+          # object when a Video or GIF is attached it will display that in Whatsapp Rich Preview.
           case media_type do
             "audio" ->
               [
index a0be383e58b70d1de05424577bcd6b00f9e77777..040b872e7034d840705ffb324628d223a9f197b3 100644 (file)
@@ -97,7 +97,8 @@ defmodule Pleroma.Web.Metadata.Providers.TwitterCard do
                 | acc
               ]
 
-            # TODO: Need the true width and height values here or Twitter renders an iFrame with a bad aspect ratio
+            # TODO: Need the true width and height values here or Twitter renders an iFrame with
+            # a bad aspect ratio
             "video" ->
               [
                 {:meta, [property: "twitter:card", content: "player"], []},
index 5fc9c9e7bdc9b3b98b153b83139d073ef60413fe..23bbde1a62345ba51c04209fb575ef822d6f234d 100644 (file)
@@ -1,10 +1,10 @@
 # Pleroma: A lightweight social networking server
-# Copyright \xc2\xa9 2017-2019 Pleroma Authors <https://pleroma.social/>
+# Copyright Â© 2017-2019 Pleroma Authors <https://pleroma.social/>
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Web.Metadata.Utils do
-  alias Pleroma.HTML
   alias Pleroma.Formatter
+  alias Pleroma.HTML
   alias Pleroma.Web.MediaProxy
 
   def scrub_html_and_truncate(%{data: %{"content" => content}} = object) do
diff --git a/lib/pleroma/web/nodeinfo/nodeinfo.ex b/lib/pleroma/web/nodeinfo/nodeinfo.ex
deleted file mode 100644 (file)
index 8b13789..0000000
+++ /dev/null
@@ -1 +0,0 @@
-
index d37c2cb83b5c70fe67866e97290627f0352b6156..a80543adf3a83729ffa14851325d208f253f375c 100644 (file)
@@ -5,10 +5,10 @@
 defmodule Pleroma.Web.OAuth.Authorization do
   use Ecto.Schema
 
-  alias Pleroma.User
   alias Pleroma.Repo
-  alias Pleroma.Web.OAuth.Authorization
+  alias Pleroma.User
   alias Pleroma.Web.OAuth.App
+  alias Pleroma.Web.OAuth.Authorization
 
   import Ecto.Changeset
   import Ecto.Query
index 36318d69bfc53c4665ccf947c0175c722bebc6a0..ec70b7ccc9379482510a4919cd5e2e30b55be1b8 100644 (file)
@@ -5,13 +5,13 @@
 defmodule Pleroma.Web.OAuth.OAuthController do
   use Pleroma.Web, :controller
 
+  alias Comeonin.Pbkdf2
+  alias Pleroma.Repo
+  alias Pleroma.User
   alias Pleroma.Web.Auth.Authenticator
+  alias Pleroma.Web.OAuth.App
   alias Pleroma.Web.OAuth.Authorization
   alias Pleroma.Web.OAuth.Token
-  alias Pleroma.Web.OAuth.App
-  alias Pleroma.Repo
-  alias Pleroma.User
-  alias Comeonin.Pbkdf2
 
   import Pleroma.Web.ControllerHelper, only: [oauth_scopes: 2]
 
index ca67632badb52c7147491b7e0b98003406b520f1..2b074b470f87ee293c806647bab32df7ba772522 100644 (file)
@@ -7,11 +7,11 @@ defmodule Pleroma.Web.OAuth.Token do
 
   import Ecto.Query
 
-  alias Pleroma.User
   alias Pleroma.Repo
-  alias Pleroma.Web.OAuth.Token
+  alias Pleroma.User
   alias Pleroma.Web.OAuth.App
   alias Pleroma.Web.OAuth.Authorization
+  alias Pleroma.Web.OAuth.Token
 
   schema "oauth_tokens" do
     field(:token, :string)
index 9e1f24bc434fcb9ad7b3ae19c842851a45f37655..1a1b74bb0b987b09a26e1a26bc5f18ac3d44c55b 100644 (file)
@@ -4,8 +4,8 @@
 
 defmodule Pleroma.Web.OStatus.ActivityRepresenter do
   alias Pleroma.Activity
-  alias Pleroma.User
   alias Pleroma.Object
+  alias Pleroma.User
   alias Pleroma.Web.OStatus.UserRepresenter
 
   require Logger
index 025d4731cf0dc7067814310d7d39cc23096197c3..b7b97e5050e7ca1a71be92db4d4e9d89ada91d21 100644 (file)
@@ -4,8 +4,8 @@
 
 defmodule Pleroma.Web.OStatus.FeedRepresenter do
   alias Pleroma.User
-  alias Pleroma.Web.OStatus
   alias Pleroma.Web.MediaProxy
+  alias Pleroma.Web.OStatus
   alias Pleroma.Web.OStatus.ActivityRepresenter
   alias Pleroma.Web.OStatus.UserRepresenter
 
index 01b52f08f9037cfaf38efcd650d1538a280eb390..b2f9f39463deab9d9324af6bd9995df55f9a1fcf 100644 (file)
@@ -4,9 +4,9 @@
 
 defmodule Pleroma.Web.OStatus.DeleteHandler do
   require Logger
-  alias Pleroma.Web.XML
   alias Pleroma.Object
   alias Pleroma.Web.ActivityPub.ActivityPub
+  alias Pleroma.Web.XML
 
   def handle_delete(entry, _doc \\ nil) do
     with id <- XML.string_from_xpath("//id", entry),
index 91ad4bc40f960c0ceb6e47a32b0b2ab8eee2b588..263d3b2dc6a73e0a0a8d66a34e92163613cd7bdf 100644 (file)
@@ -3,10 +3,10 @@
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Web.OStatus.FollowHandler do
-  alias Pleroma.Web.XML
-  alias Pleroma.Web.OStatus
-  alias Pleroma.Web.ActivityPub.ActivityPub
   alias Pleroma.User
+  alias Pleroma.Web.ActivityPub.ActivityPub
+  alias Pleroma.Web.OStatus
+  alias Pleroma.Web.XML
 
   def handle(entry, doc) do
     with {:ok, actor} <- OStatus.find_make_or_update_user(doc),
index c2e585cac18f7a72030661161a93df1f98202a60..770a71a0a3c22c4d93a026331c30519ca87d7866 100644 (file)
@@ -4,13 +4,14 @@
 
 defmodule Pleroma.Web.OStatus.NoteHandler do
   require Logger
-  alias Pleroma.Web.OStatus
-  alias Pleroma.Web.XML
+
   alias Pleroma.Activity
   alias Pleroma.Object
   alias Pleroma.Web.ActivityPub.ActivityPub
   alias Pleroma.Web.ActivityPub.Utils
   alias Pleroma.Web.CommonAPI
+  alias Pleroma.Web.OStatus
+  alias Pleroma.Web.XML
 
   @doc """
   Get the context for this note. Uses this:
@@ -18,13 +19,13 @@ defmodule Pleroma.Web.OStatus.NoteHandler do
   2. The conversation reference in the ostatus xml
   3. A newly generated context id.
   """
-  def get_context(entry, inReplyTo) do
+  def get_context(entry, in_reply_to) do
     context =
       (XML.string_from_xpath("//ostatus:conversation[1]", entry) ||
          XML.string_from_xpath("//ostatus:conversation[1]/@ref", entry) || "")
       |> String.trim()
 
-    with %{data: %{"context" => context}} <- Object.get_cached_by_ap_id(inReplyTo) do
+    with %{data: %{"context" => context}} <- Object.get_cached_by_ap_id(in_reply_to) do
       context
     else
       _e ->
@@ -87,14 +88,14 @@ defmodule Pleroma.Web.OStatus.NoteHandler do
     Map.put(note, "external_url", url)
   end
 
-  def fetch_replied_to_activity(entry, inReplyTo) do
-    with %Activity{} = activity <- Activity.get_create_by_object_ap_id(inReplyTo) do
+  def fetch_replied_to_activity(entry, in_reply_to) do
+    with %Activity{} = activity <- Activity.get_create_by_object_ap_id(in_reply_to) do
       activity
     else
       _e ->
-        with inReplyToHref when not is_nil(inReplyToHref) <-
+        with in_reply_to_href when not is_nil(in_reply_to_href) <-
                XML.string_from_xpath("//thr:in-reply-to[1]/@href", entry),
-             {:ok, [activity | _]} <- OStatus.fetch_activity_from_url(inReplyToHref) do
+             {:ok, [activity | _]} <- OStatus.fetch_activity_from_url(in_reply_to_href) do
           activity
         else
           _e -> nil
@@ -110,11 +111,12 @@ defmodule Pleroma.Web.OStatus.NoteHandler do
          {:ok, actor} <- OStatus.find_make_or_update_user(author),
          content_html <- OStatus.get_content(entry),
          cw <- OStatus.get_cw(entry),
-         inReplyTo <- XML.string_from_xpath("//thr:in-reply-to[1]/@ref", entry),
-         inReplyToActivity <- fetch_replied_to_activity(entry, inReplyTo),
-         inReplyTo <- (inReplyToActivity && inReplyToActivity.data["object"]["id"]) || inReplyTo,
+         in_reply_to <- XML.string_from_xpath("//thr:in-reply-to[1]/@ref", entry),
+         in_reply_to_activity <- fetch_replied_to_activity(entry, in_reply_to),
+         in_reply_to <-
+           (in_reply_to_activity && in_reply_to_activity.data["object"]["id"]) || in_reply_to,
          attachments <- OStatus.get_attachments(entry),
-         context <- get_context(entry, inReplyTo),
+         context <- get_context(entry, in_reply_to),
          tags <- OStatus.get_tags(entry),
          mentions <- get_mentions(entry),
          to <- make_to_list(actor, mentions),
@@ -128,7 +130,7 @@ defmodule Pleroma.Web.OStatus.NoteHandler do
              context,
              content_html,
              attachments,
-             inReplyToActivity,
+             in_reply_to_activity,
              [],
              cw
            ),
@@ -140,8 +142,8 @@ defmodule Pleroma.Web.OStatus.NoteHandler do
          # TODO: Handle this case in make_note_data
          note <-
            if(
-             inReplyTo && !inReplyToActivity,
-             do: note |> Map.put("inReplyTo", inReplyTo),
+             in_reply_to && !in_reply_to_activity,
+             do: note |> Map.put("inReplyTo", in_reply_to),
              else: note
            ) do
       ActivityPub.create(%{
index c9085894d115cbb2e849452c3d4ff054324b0613..6596ada3bbfaf4d5fe2ae4ef3e76c15bd861433d 100644 (file)
@@ -3,10 +3,10 @@
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Web.OStatus.UnfollowHandler do
-  alias Pleroma.Web.XML
-  alias Pleroma.Web.OStatus
-  alias Pleroma.Web.ActivityPub.ActivityPub
   alias Pleroma.User
+  alias Pleroma.Web.ActivityPub.ActivityPub
+  alias Pleroma.Web.OStatus
+  alias Pleroma.Web.XML
 
   def handle(entry, doc) do
     with {:ok, actor} <- OStatus.find_make_or_update_user(doc),
index b4f5761ac2d15f86c1645741117a749e149aebfc..266f86bf47d35bde3f605ec4251cd6e4ddac4ac7 100644 (file)
@@ -9,19 +9,19 @@ defmodule Pleroma.Web.OStatus do
   import Pleroma.Web.XML
   require Logger
 
+  alias Pleroma.Activity
+  alias Pleroma.Object
   alias Pleroma.Repo
   alias Pleroma.User
   alias Pleroma.Web
-  alias Pleroma.Object
-  alias Pleroma.Activity
   alias Pleroma.Web.ActivityPub.ActivityPub
   alias Pleroma.Web.ActivityPub.Transmogrifier
-  alias Pleroma.Web.WebFinger
-  alias Pleroma.Web.Websub
+  alias Pleroma.Web.OStatus.DeleteHandler
   alias Pleroma.Web.OStatus.FollowHandler
-  alias Pleroma.Web.OStatus.UnfollowHandler
   alias Pleroma.Web.OStatus.NoteHandler
-  alias Pleroma.Web.OStatus.DeleteHandler
+  alias Pleroma.Web.OStatus.UnfollowHandler
+  alias Pleroma.Web.WebFinger
+  alias Pleroma.Web.Websub
 
   def is_representable?(%Activity{data: data}) do
     object = Object.normalize(data["object"])
index 4e963774a9eb1e9226c4d2561f03fc63b5fa8e35..0579a5f3de83109a5484829c244eba01bed98283 100644 (file)
@@ -9,13 +9,13 @@ defmodule Pleroma.Web.OStatus.OStatusController do
   alias Pleroma.Object
   alias Pleroma.User
   alias Pleroma.Web.ActivityPub.ActivityPub
-  alias Pleroma.Web.ActivityPub.Visibility
   alias Pleroma.Web.ActivityPub.ActivityPubController
   alias Pleroma.Web.ActivityPub.ObjectView
-  alias Pleroma.Web.OStatus.ActivityRepresenter
-  alias Pleroma.Web.OStatus.FeedRepresenter
+  alias Pleroma.Web.ActivityPub.Visibility
   alias Pleroma.Web.Federator
   alias Pleroma.Web.OStatus
+  alias Pleroma.Web.OStatus.ActivityRepresenter
+  alias Pleroma.Web.OStatus.FeedRepresenter
   alias Pleroma.Web.XML
 
   plug(Pleroma.Web.FederatingPlug when action in [:salmon_incoming])
index 0437ffd00cadb19ea6adad593493b639c611141a..8635731852b9921b61093d1b5c5e432af17d99fa 100644 (file)
@@ -5,13 +5,13 @@
 defmodule Pleroma.Web.Push.Impl do
   @moduledoc "The module represents implementation push web notification"
 
-  alias Pleroma.Repo
-  alias Pleroma.User
   alias Pleroma.Activity
+  alias Pleroma.Notification
   alias Pleroma.Object
-  alias Pleroma.Web.Push.Subscription
+  alias Pleroma.Repo
+  alias Pleroma.User
   alias Pleroma.Web.Metadata.Utils
-  alias Pleroma.Notification
+  alias Pleroma.Web.Push.Subscription
 
   require Logger
   import Ecto.Query
index 951dab53531fd6f13c28bac7cd6eb5fdf381b853..5259e8e33083c248f38621fcfdc693e63dcb2fc9 100644 (file)
@@ -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
index c90bd2bda005e849f7740a79aa68f280175c5b49..da301fbbccebc2a50a5187255245437822496cd5 100644 (file)
@@ -82,8 +82,8 @@ defmodule Pleroma.Web.Push.Subscription do
   end
 
   # Some webpush clients (e.g. iOS Toot!) use an non urlsafe base64 as an encoding for the key.
-  # However, the web push rfs specify to use base64 urlsafe, and the `web_push_encryption` library we use
-  # requires the key to be properly encoded. So we just convert base64 to urlsafe base64.
+  # However, the web push rfs specify to use base64 urlsafe, and the `web_push_encryption` library
+  # we use requires the key to be properly encoded. So we just convert base64 to urlsafe base64.
   defp ensure_base64_urlsafe(string) do
     string
     |> String.replace("+", "-")
index 8317a11624d8caceca3edfdeca82abd885678e5a..92c61ff511a603bb30625fcf632f52e97522b5b7 100644 (file)
@@ -4,8 +4,8 @@
 
 defmodule Pleroma.Web.RichMedia.Helpers do
   alias Pleroma.Activity
-  alias Pleroma.Object
   alias Pleroma.HTML
+  alias Pleroma.Object
   alias Pleroma.Web.RichMedia.Parser
 
   defp validate_page_url(page_url) when is_binary(page_url) do
index 65a90e31e51122b9d0104b249486f231ab1ae99d..c56e4a421a98074f1cc7283e33fee3cb9d12ae75 100644 (file)
@@ -631,8 +631,8 @@ end
 
 defmodule Fallback.RedirectController do
   use Pleroma.Web, :controller
-  alias Pleroma.Web.Metadata
   alias Pleroma.User
+  alias Pleroma.Web.Metadata
 
   def redirector(conn, _params, code \\ 200) do
     conn
index 0a69aa1ec9091530d8c99b4859afb898f4f74544..0a9e51656db5e9fb56bb768c81694976a257ccb9 100644 (file)
@@ -9,8 +9,8 @@ defmodule Pleroma.Web.Salmon do
 
   alias Pleroma.Instances
   alias Pleroma.User
-  alias Pleroma.Web.XML
   alias Pleroma.Web.OStatus.ActivityRepresenter
+  alias Pleroma.Web.XML
 
   require Logger
 
@@ -86,10 +86,10 @@ defmodule Pleroma.Web.Salmon do
   # Native generation of RSA keys is only available since OTP 20+ and in default build conditions
   # We try at compile time to generate natively an RSA key otherwise we fallback on the old way.
   try do
-    _ = :public_key.generate_key({:rsa, 2048, 65537})
+    _ = :public_key.generate_key({:rsa, 2048, 65_537})
 
     def generate_rsa_pem do
-      key = :public_key.generate_key({:rsa, 2048, 65537})
+      key = :public_key.generate_key({:rsa, 2048, 65_537})
       entry = :public_key.pem_entry_encode(:RSAPrivateKey, key)
       pem = :public_key.pem_encode([entry]) |> String.trim_trailing()
       {:ok, pem}
index ad888c36151675111f4326e950fd91a19adf0a4c..aec11a79f6ba2ff016416ea853502fd4896951c5 100644 (file)
@@ -5,11 +5,11 @@
 defmodule Pleroma.Web.Streamer do
   use GenServer
   require Logger
-  alias Pleroma.User
-  alias Pleroma.Notification
   alias Pleroma.Activity
+  alias Pleroma.Notification
   alias Pleroma.Object
   alias Pleroma.Repo
+  alias Pleroma.User
   alias Pleroma.Web.ActivityPub.Visibility
 
   @keepalive_interval :timer.seconds(30)
index e2fdedb25f94cab9182a44726697741943f1fc44..8ed02a93fe6e55c1db5ee4d52b7e9c6325b273c4 100644 (file)
@@ -10,13 +10,13 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
   alias Comeonin.Pbkdf2
   alias Pleroma.Emoji
   alias Pleroma.PasswordResetToken
-  alias Pleroma.User
   alias Pleroma.Repo
+  alias Pleroma.User
   alias Pleroma.Web
+  alias Pleroma.Web.ActivityPub.ActivityPub
   alias Pleroma.Web.CommonAPI
   alias Pleroma.Web.OStatus
   alias Pleroma.Web.WebFinger
-  alias Pleroma.Web.ActivityPub.ActivityPub
 
   def show_password_reset(conn, %{"token" => token}) do
     with %{used: false} = token <- Repo.get_by(PasswordResetToken, %{token: token}),
index dcb15b9a92ee6c9a5aca7a9e23e3a15611645a0b..a22e765c7ed1d7f0c8aa5c83261f1492d59aa77a 100644 (file)
@@ -3,16 +3,16 @@
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
-  alias Pleroma.UserInviteToken
-  alias Pleroma.User
   alias Pleroma.Activity
-  alias Pleroma.Repo
+  alias Pleroma.Mailer
   alias Pleroma.Object
+  alias Pleroma.Repo
+  alias Pleroma.User
   alias Pleroma.UserEmail
-  alias Pleroma.Mailer
+  alias Pleroma.UserInviteToken
   alias Pleroma.Web.ActivityPub.ActivityPub
-  alias Pleroma.Web.TwitterAPI.UserView
   alias Pleroma.Web.CommonAPI
+  alias Pleroma.Web.TwitterAPI.UserView
 
   import Ecto.Query
 
@@ -133,7 +133,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
   end
 
   def register_user(params) do
-    tokenString = params["token"]
+    token_string = params["token"]
 
     params = %{
       nickname: params["nickname"],
@@ -170,8 +170,8 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
 
       # no need to query DB if registration is open
       token =
-        unless registrations_open || is_nil(tokenString) do
-          Repo.get_by(UserInviteToken, %{token: tokenString})
+        unless registrations_open || is_nil(token_string) do
+          Repo.get_by(UserInviteToken, %{token: token_string})
         end
 
       cond do
index 5e4ebb8e8993fa9a385163cbfd19c26f09efba00..8221b2324c2a2fcb7acfe244d798a81474b985a6 100644 (file)
@@ -8,23 +8,21 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
   import Pleroma.Web.ControllerHelper, only: [json_response: 3]
 
   alias Ecto.Changeset
-  alias Pleroma.Web.TwitterAPI.{TwitterAPI, UserView, ActivityView, NotificationView, TokenView}
-  alias Pleroma.Web.CommonAPI
-  alias Pleroma.{Repo, Activity, Object, User, Notification}
-  alias Pleroma.Web.OAuth.Token
+  alias Pleroma.Activity
+  alias Pleroma.Notification
+  alias Pleroma.Object
+  alias Pleroma.Repo
+  alias Pleroma.User
   alias Pleroma.Web.ActivityPub.ActivityPub
-  alias Pleroma.Web.ActivityPub.Visibility
   alias Pleroma.Web.ActivityPub.Utils
+  alias Pleroma.Web.ActivityPub.Visibility
   alias Pleroma.Web.CommonAPI
+  alias Pleroma.Web.OAuth.Token
   alias Pleroma.Web.TwitterAPI.ActivityView
   alias Pleroma.Web.TwitterAPI.NotificationView
+  alias Pleroma.Web.TwitterAPI.TokenView
   alias Pleroma.Web.TwitterAPI.TwitterAPI
   alias Pleroma.Web.TwitterAPI.UserView
-  alias Pleroma.Activity
-  alias Pleroma.Object
-  alias Pleroma.Notification
-  alias Pleroma.Repo
-  alias Pleroma.User
 
   require Logger
 
index 02ca4ee42b8412c3e5c263183b6af23de9f3b028..4926f007e95c0d3ec4979ce78b37c0bd6fe36eca 100644 (file)
@@ -14,9 +14,9 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do
   alias Pleroma.Web.CommonAPI.Utils
   alias Pleroma.Web.MastodonAPI.StatusView
   alias Pleroma.Web.TwitterAPI.ActivityView
+  alias Pleroma.Web.TwitterAPI.Representers.ObjectRepresenter
   alias Pleroma.Web.TwitterAPI.TwitterAPI
   alias Pleroma.Web.TwitterAPI.UserView
-  alias Pleroma.Web.TwitterAPI.Representers.ObjectRepresenter
 
   import Ecto.Query
   require Logger
index 5ea5ae48e809fe21b3770b05c5e7f1a389d552fe..32c3455f500c856943cc9638788b653fe1e060c5 100644 (file)
@@ -6,11 +6,11 @@ defmodule Pleroma.Web.WebFinger do
   @httpoison Application.get_env(:pleroma, :httpoison)
 
   alias Pleroma.User
-  alias Pleroma.XmlBuilder
   alias Pleroma.Web
-  alias Pleroma.Web.XML
-  alias Pleroma.Web.Salmon
   alias Pleroma.Web.OStatus
+  alias Pleroma.Web.Salmon
+  alias Pleroma.Web.XML
+  alias Pleroma.XmlBuilder
   require Jason
   require Logger
 
index c00ec08582aa328598d14fa02019d14833ecea1f..3ffa6b416b4391bc3d16325c8ed3e2ea37f365f5 100644 (file)
@@ -6,14 +6,14 @@ defmodule Pleroma.Web.Websub do
   alias Ecto.Changeset
   alias Pleroma.Instances
   alias Pleroma.Repo
-  alias Pleroma.Web.Websub.WebsubServerSubscription
-  alias Pleroma.Web.Websub.WebsubClientSubscription
-  alias Pleroma.Web.OStatus.FeedRepresenter
-  alias Pleroma.Web.XML
   alias Pleroma.Web.Endpoint
+  alias Pleroma.Web.Federator
   alias Pleroma.Web.OStatus
+  alias Pleroma.Web.OStatus.FeedRepresenter
   alias Pleroma.Web.Router.Helpers
-  alias Pleroma.Web.Federator
+  alias Pleroma.Web.Websub.WebsubClientSubscription
+  alias Pleroma.Web.Websub.WebsubServerSubscription
+  alias Pleroma.Web.XML
   require Logger
 
   import Ecto.Query
@@ -200,8 +200,8 @@ defmodule Pleroma.Web.Websub do
          uri when not is_nil(uri) <- XML.string_from_xpath("/feed/author[1]/uri", doc),
          hub when not is_nil(hub) <- XML.string_from_xpath(~S{/feed/link[@rel="hub"]/@href}, doc) do
       name = XML.string_from_xpath("/feed/author[1]/name", doc)
-      preferredUsername = XML.string_from_xpath("/feed/author[1]/poco:preferredUsername", doc)
-      displayName = XML.string_from_xpath("/feed/author[1]/poco:displayName", doc)
+      preferred_username = XML.string_from_xpath("/feed/author[1]/poco:preferredUsername", doc)
+      display_name = XML.string_from_xpath("/feed/author[1]/poco:displayName", doc)
       avatar = OStatus.make_avatar_object(doc)
       bio = XML.string_from_xpath("/feed/author[1]/summary", doc)
 
@@ -209,8 +209,8 @@ defmodule Pleroma.Web.Websub do
        %{
          "uri" => uri,
          "hub" => hub,
-         "nickname" => preferredUsername || name,
-         "name" => displayName || name,
+         "nickname" => preferred_username || name,
+         "name" => display_name || name,
          "host" => URI.parse(uri).host,
          "avatar" => avatar,
          "bio" => bio
index ad40f1b9471f5ddbbbf601fa1c5967e55f933a3e..9e8b48b80c2c94479cbb2e7873193935bbaa56e4 100644 (file)
@@ -7,8 +7,8 @@ defmodule Pleroma.Web.Websub.WebsubController do
 
   alias Pleroma.Repo
   alias Pleroma.User
-  alias Pleroma.Web.Websub
   alias Pleroma.Web.Federator
+  alias Pleroma.Web.Websub
   alias Pleroma.Web.Websub.WebsubClientSubscription
 
   require Logger
index 0c513b6e75feab22454ee2df23a5afbef7d37dae..b42c9ef073deec7672a24cc43b79d20758d9b5f6 100644 (file)
@@ -7,9 +7,9 @@ defmodule Pleroma.Integration.MastodonWebsocketTest do
 
   import Pleroma.Factory
 
+  alias Pleroma.Integration.WebsocketClient
   alias Pleroma.Web.CommonAPI
   alias Pleroma.Web.OAuth
-  alias Pleroma.Integration.WebsocketClient
   alias Pleroma.Web.Streamer
 
   @path Pleroma.Web.Endpoint.url()
index ccb518dec75408431759a7f7db975925ec00193c..d55c86ccc175a684bd532df6a02e4d3688c26407 100644 (file)
@@ -5,8 +5,8 @@
 defmodule Pleroma.JobsTest do
   use ExUnit.Case, async: true
 
-  alias Pleroma.Jobs
   alias Jobs.WorkerMock
+  alias Pleroma.Jobs
 
   setup do
     state = %{
index 755874a3da9ee9846c265821bca0cf3e63513c9c..12b4292aa8c4259aa977303b3a0695abb9dbcf5c 100644 (file)
@@ -4,11 +4,11 @@
 
 defmodule Pleroma.NotificationTest do
   use Pleroma.DataCase
-  alias Pleroma.Web.TwitterAPI.TwitterAPI
-  alias Pleroma.Web.CommonAPI
-  alias Pleroma.User
   alias Pleroma.Notification
+  alias Pleroma.User
   alias Pleroma.Web.ActivityPub.Transmogrifier
+  alias Pleroma.Web.CommonAPI
+  alias Pleroma.Web.TwitterAPI.TwitterAPI
   import Pleroma.Factory
 
   describe "create_notifications" do
index a820a34ee87db85676218dd0b8589f5470ebcc89..911757d57c601e83f5e54dbd668247d6e818c2ab 100644 (file)
@@ -5,8 +5,8 @@
 defmodule Pleroma.ObjectTest do
   use Pleroma.DataCase
   import Pleroma.Factory
-  alias Pleroma.Repo
   alias Pleroma.Object
+  alias Pleroma.Repo
 
   test "returns an object by it's AP id" do
     object = insert(:note)
index 611a5be18f7364bb32d29551e84b5572cfb05f77..f58e1b0ad370df0422fd623657b78334bb992664 100644 (file)
@@ -1,6 +1,6 @@
 defmodule Pleroma.Builders.UserBuilder do
-  alias Pleroma.User
   alias Pleroma.Repo
+  alias Pleroma.User
 
   def build(data \\ %{}) do
     user = %User{
index 9061f2b4549cdf4d4001ef2e7a4a231f9df1383e..ef4e68bc554bb066f72f2d858d7e2cdc2f6f9faf 100644 (file)
@@ -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
index 64ff07753af295814a6fd5f7dcb29e923022ff3d..c9d90fa2e13adc77b1ac5c2555c3344c4fd330d4 100644 (file)
@@ -4,10 +4,10 @@
 
 defmodule Mix.Tasks.Pleroma.RelayTest do
   alias Pleroma.Activity
+  alias Pleroma.User
   alias Pleroma.Web.ActivityPub.ActivityPub
-  alias Pleroma.Web.ActivityPub.Utils
   alias Pleroma.Web.ActivityPub.Relay
-  alias Pleroma.User
+  alias Pleroma.Web.ActivityPub.Utils
   use Pleroma.DataCase
 
   setup_all do
index 3a5f3c24033eaee7fa19a6773c47810f156da574..c57eb2c0691dcfe9938a99ec0fd189d74396bfd2 100644 (file)
@@ -3,8 +3,8 @@
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.UserTest do
-  alias Pleroma.Builders.UserBuilder
   alias Pleroma.Activity
+  alias Pleroma.Builders.UserBuilder
   alias Pleroma.Repo
   alias Pleroma.User
   alias Pleroma.Web.CommonAPI
index 6bd4493f5b47d0b325364b04f9e29a0df323966e..a1e83b380ace08b7a6f9640c663f3d0abef006b5 100644 (file)
@@ -5,13 +5,13 @@
 defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
   use Pleroma.Web.ConnCase
   import Pleroma.Factory
-  alias Pleroma.Web.ActivityPub.UserView
-  alias Pleroma.Web.ActivityPub.ObjectView
+  alias Pleroma.Activity
+  alias Pleroma.Instances
   alias Pleroma.Object
   alias Pleroma.Repo
-  alias Pleroma.Activity
   alias Pleroma.User
-  alias Pleroma.Instances
+  alias Pleroma.Web.ActivityPub.ObjectView
+  alias Pleroma.Web.ActivityPub.UserView
 
   setup_all do
     Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
index 10c5258d0cb5787b39bfbb41cd8076100986e2d4..2b83bfb1d05c6cf5ab4c944b5eb78d1cef6bd8e2 100644 (file)
@@ -4,14 +4,14 @@
 
 defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
   use Pleroma.DataCase
-  alias Pleroma.Web.ActivityPub.ActivityPub
-  alias Pleroma.Web.ActivityPub.Utils
-  alias Pleroma.Web.CommonAPI
   alias Pleroma.Activity
+  alias Pleroma.Builders.ActivityBuilder
+  alias Pleroma.Instances
   alias Pleroma.Object
   alias Pleroma.User
-  alias Pleroma.Instances
-  alias Pleroma.Builders.ActivityBuilder
+  alias Pleroma.Web.ActivityPub.ActivityPub
+  alias Pleroma.Web.ActivityPub.Utils
+  alias Pleroma.Web.CommonAPI
 
   import Pleroma.Factory
   import Tesla.Mock
index 86c66deff6af1a5b0fd60c9bbfcb55a69dd3a3c1..8184dbbaebde7c3a8cdb350a9267f776095dc007 100644 (file)
@@ -4,13 +4,13 @@
 
 defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
   use Pleroma.DataCase
+  alias Pleroma.Activity
+  alias Pleroma.Repo
+  alias Pleroma.User
+  alias Pleroma.Web.ActivityPub.ActivityPub
   alias Pleroma.Web.ActivityPub.Transmogrifier
   alias Pleroma.Web.ActivityPub.Utils
-  alias Pleroma.Web.ActivityPub.ActivityPub
   alias Pleroma.Web.OStatus
-  alias Pleroma.Activity
-  alias Pleroma.User
-  alias Pleroma.Repo
   alias Pleroma.Web.Websub.WebsubClientSubscription
 
   import Pleroma.Factory
index 1300039aacce3702f949f239f79bc12b5ced9216..2bd3ddf932c632ab017128e81a69ff8bd31643e4 100644 (file)
@@ -1,7 +1,7 @@
 defmodule Pleroma.Web.ActivityPub.UtilsTest do
   use Pleroma.DataCase
-  alias Pleroma.Web.CommonAPI
   alias Pleroma.Web.ActivityPub.Utils
+  alias Pleroma.Web.CommonAPI
 
   import Pleroma.Factory
 
index d144a77fc7981d8cf27169d5ed9589bfe188cc74..d939fc5a74038cf3ee2dec70dbc549c1a740abec 100644 (file)
@@ -2,8 +2,8 @@ defmodule Pleroma.Web.ActivityPub.ObjectViewTest do
   use Pleroma.DataCase
   import Pleroma.Factory
 
-  alias Pleroma.Web.CommonAPI
   alias Pleroma.Web.ActivityPub.ObjectView
+  alias Pleroma.Web.CommonAPI
 
   test "renders a note object" do
     note = insert(:note)
index 1172b7455db413044fac7171c90680f524cff9eb..24b96c4aa7429925694ea5e0bda3b86dc810dc81 100644 (file)
@@ -1,8 +1,8 @@
 defmodule Pleroma.Web.ActivityPub.VisibilityTest do
   use Pleroma.DataCase
 
-  alias Pleroma.Web.CommonAPI
   alias Pleroma.Web.ActivityPub.Visibility
+  alias Pleroma.Web.CommonAPI
   import Pleroma.Factory
 
   setup do
index 9ba320f5924ed06ed401640abd8cec5bb528d28b..181813c76492442fb99ec328ed939e81e642223d 100644 (file)
@@ -4,9 +4,9 @@
 
 defmodule Pleroma.Web.CommonAPITest do
   use Pleroma.DataCase
-  alias Pleroma.Web.CommonAPI
-  alias Pleroma.User
   alias Pleroma.Activity
+  alias Pleroma.User
+  alias Pleroma.Web.CommonAPI
 
   import Pleroma.Factory
 
index 684f2a23f662c5dedcfe86c8639676fd81fd9793..4c97b0d62930024f6464569fa9a74f75e366f83b 100644 (file)
@@ -3,9 +3,9 @@
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Web.CommonAPI.UtilsTest do
+  alias Pleroma.Builders.UserBuilder
   alias Pleroma.Web.CommonAPI.Utils
   alias Pleroma.Web.Endpoint
-  alias Pleroma.Builders.UserBuilder
   use Pleroma.DataCase
 
   test "it adds attachment links to a given text and attachment set" do
index 08279f230f7953285616fa67f6384fb60a0509d4..52729eb507627db0255f96266439539664244c93 100644 (file)
@@ -3,9 +3,9 @@
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Web.FederatorTest do
+  alias Pleroma.Instances
   alias Pleroma.Web.CommonAPI
   alias Pleroma.Web.Federator
-  alias Pleroma.Instances
   use Pleroma.DataCase
   import Pleroma.Factory
   import Mock
index a158c0a42a40e3130d7f33b046a30cbc3d9d62ce..d28730994567b66bff6f812a137729fc257e46f8 100644 (file)
@@ -3,8 +3,8 @@
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Instances.InstanceTest do
-  alias Pleroma.Repo
   alias Pleroma.Instances.Instance
+  alias Pleroma.Repo
 
   use Pleroma.DataCase
 
index 2530c09fe8fd20a0594cadf5526e609532bdb203..f0d84edeadf7d38af19b46eb750745d65368cd11 100644 (file)
@@ -102,7 +102,8 @@ defmodule Pleroma.InstancesTest do
     end
   end
 
-  # Note: implementation-specific (e.g. Instance) details of set_unreachable/1 should be tested in implementation-specific tests
+  # Note: implementation-specific (e.g. Instance) details of set_unreachable/1
+  # should be tested in implementation-specific tests
   describe "set_unreachable/1" do
     test "returns error status on non-binary input" do
       assert {:error, _} = Instances.set_unreachable(nil)
index 6be66ef6367db297ecd7797f45aa48d2f466f6ca..c2ffc21da8612fd432028b6cefb7165a08e0f339 100644 (file)
@@ -5,8 +5,8 @@
 defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
   use Pleroma.DataCase
   import Pleroma.Factory
-  alias Pleroma.Web.MastodonAPI.AccountView
   alias Pleroma.User
+  alias Pleroma.Web.MastodonAPI.AccountView
 
   test "Represent a user account" do
     source_data = %{
index 2caf514bbe39fd6bc03a2ff5c162fd79e533128d..059d5237d678b496d42b332767b396834fb42ee8 100644 (file)
@@ -5,17 +5,17 @@
 defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
   use Pleroma.Web.ConnCase
 
-  alias Pleroma.Web.TwitterAPI.TwitterAPI
-  alias Pleroma.Repo
-  alias Pleroma.User
-  alias Pleroma.Object
+  alias Ecto.Changeset
   alias Pleroma.Activity
   alias Pleroma.Notification
-  alias Pleroma.Web.OStatus
-  alias Pleroma.Web.CommonAPI
+  alias Pleroma.Object
+  alias Pleroma.Repo
+  alias Pleroma.User
   alias Pleroma.Web.ActivityPub.ActivityPub
+  alias Pleroma.Web.CommonAPI
   alias Pleroma.Web.MastodonAPI.FilterView
-  alias Ecto.Changeset
+  alias Pleroma.Web.OStatus
+  alias Pleroma.Web.TwitterAPI.TwitterAPI
   import Pleroma.Factory
   import ExUnit.CaptureLog
   import Tesla.Mock
@@ -1632,9 +1632,10 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
       assert user = json_response(conn, 200)
 
       assert user["note"] ==
-               "I drink <a class=\"hashtag\" data-tag=\"cofe\" href=\"http://localhost:4001/tag/cofe\">#cofe</a> with <span class=\"h-card\"><a data-user=\"#{
-                 user2.id
-               }\" class=\"u-url mention\" href=\"#{user2.ap_id}\">@<span>#{user2.nickname}</span></a></span>"
+               ~s(I drink <a class="hashtag" data-tag="cofe" href="http://localhost:4001/tag/cofe">#cofe</a> with <span class="h-card"><a data-user=") <>
+                 user2.id <>
+                 ~s(" class="u-url mention" href=") <>
+                 user2.ap_id <> ~s(">@<span>) <> user2.nickname <> ~s(</span></a></span>)
     end
 
     test "updates the user's locking status", %{conn: conn} do
index 485a0b4f738e114909a7b4085f392d751a41f379..3eec2cb5beea469e3508d874dee749f26397857c 100644 (file)
@@ -5,13 +5,13 @@
 defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
   use Pleroma.DataCase
 
+  alias Pleroma.Activity
+  alias Pleroma.User
+  alias Pleroma.Web.ActivityPub.ActivityPub
+  alias Pleroma.Web.CommonAPI
   alias Pleroma.Web.MastodonAPI.AccountView
   alias Pleroma.Web.MastodonAPI.StatusView
-  alias Pleroma.User
   alias Pleroma.Web.OStatus
-  alias Pleroma.Web.CommonAPI
-  alias Pleroma.Web.ActivityPub.ActivityPub
-  alias Pleroma.Activity
   import Pleroma.Factory
   import Tesla.Mock
 
index 306db2e624ff8d616600c81f3519cad432deb950..d8b008437b8bbf842cc09dafbf14e5d86966f5cd 100644 (file)
@@ -4,8 +4,8 @@
 
 defmodule Pleroma.Web.OAuth.AuthorizationTest do
   use Pleroma.DataCase
-  alias Pleroma.Web.OAuth.Authorization
   alias Pleroma.Web.OAuth.App
+  alias Pleroma.Web.OAuth.Authorization
   import Pleroma.Factory
 
   setup do
index 62444a0fa4c6cc41188d632843a51a93ff9c2c78..ad2a49f09eb45069ea291a6c8d6b3c6d252f932f 100644 (file)
@@ -4,10 +4,10 @@
 
 defmodule Pleroma.Web.OAuth.TokenTest do
   use Pleroma.DataCase
+  alias Pleroma.Repo
   alias Pleroma.Web.OAuth.App
   alias Pleroma.Web.OAuth.Authorization
   alias Pleroma.Web.OAuth.Token
-  alias Pleroma.Repo
 
   import Pleroma.Factory
 
index eebc5c040057036de50385267ac64e93f59dafde..5cb135b4c065f35390e02f55e2f09e8c678f9f4d 100644 (file)
@@ -5,12 +5,12 @@
 defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do
   use Pleroma.DataCase
 
-  alias Pleroma.Web.OStatus.ActivityRepresenter
   alias Pleroma.Activity
-  alias Pleroma.User
   alias Pleroma.Object
+  alias Pleroma.User
   alias Pleroma.Web.ActivityPub.ActivityPub
   alias Pleroma.Web.OStatus
+  alias Pleroma.Web.OStatus.ActivityRepresenter
 
   import Pleroma.Factory
   import Tesla.Mock
index efd4e7217ed1cb7e394fedf6b0a7625a76581ca6..3c7b126e74afda7b2d64be7b673793812c3d8d0a 100644 (file)
@@ -6,10 +6,10 @@ defmodule Pleroma.Web.OStatus.FeedRepresenterTest do
   use Pleroma.DataCase
   import Pleroma.Factory
   alias Pleroma.User
+  alias Pleroma.Web.OStatus
   alias Pleroma.Web.OStatus.ActivityRepresenter
   alias Pleroma.Web.OStatus.FeedRepresenter
   alias Pleroma.Web.OStatus.UserRepresenter
-  alias Pleroma.Web.OStatus
 
   test "returns a feed of the last 20 items of the user" do
     note_activity = insert(:note_activity)
index d295cc539f9d194a29ab66965c107a83e2943919..412d894fd83b1f31c1c1b472e2e32273e1759cca 100644 (file)
@@ -4,9 +4,9 @@ defmodule Pleroma.Web.OStatus.DeleteHandlingTest do
   import Pleroma.Factory
   import Tesla.Mock
 
-  alias Pleroma.Repo
   alias Pleroma.Activity
   alias Pleroma.Object
+  alias Pleroma.Repo
   alias Pleroma.Web.OStatus
 
   setup do
index da9c72be82b54b5cf49f059cdd4a00ad390cc36e..2950f11c0c2f8dd915d9ef424480e32367423665 100644 (file)
@@ -5,9 +5,9 @@
 defmodule Pleroma.Web.OStatus.OStatusControllerTest do
   use Pleroma.Web.ConnCase
   import Pleroma.Factory
-  alias Pleroma.User
-  alias Pleroma.Repo
   alias Pleroma.Object
+  alias Pleroma.Repo
+  alias Pleroma.User
   alias Pleroma.Web.CommonAPI
   alias Pleroma.Web.OStatus.ActivityRepresenter
 
index b4b19ab05351167166f31598b30317b13ca94986..76b90e186e6de31603607f3b019733951bdb3ca2 100644 (file)
@@ -4,13 +4,13 @@
 
 defmodule Pleroma.Web.OStatusTest do
   use Pleroma.DataCase
-  alias Pleroma.Web.OStatus
-  alias Pleroma.Web.XML
+  alias Pleroma.Activity
+  alias Pleroma.Instances
   alias Pleroma.Object
   alias Pleroma.Repo
   alias Pleroma.User
-  alias Pleroma.Activity
-  alias Pleroma.Instances
+  alias Pleroma.Web.OStatus
+  alias Pleroma.Web.XML
   import Pleroma.Factory
   import ExUnit.CaptureLog
 
index 9e583ba40229e6cfb5247c93c8925670f47e2726..265e1abbd44588dac1674851f3ece4b0c54ce7de 100644 (file)
@@ -4,10 +4,10 @@
 
 defmodule Pleroma.Web.Salmon.SalmonTest do
   use Pleroma.DataCase
-  alias Pleroma.Web.Salmon
   alias Pleroma.Activity
   alias Pleroma.Repo
   alias Pleroma.User
+  alias Pleroma.Web.Salmon
   import Pleroma.Factory
 
   @magickey "RSA.pu0s-halox4tu7wmES1FVSx6u-4wc0YrUFXcqWXZG4-27UmbCOpMQftRCldNRfyA-qLbz-eqiwQhh-1EwUvjsD4cYbAHNGHwTvDOyx5AKthQUP44ykPv7kjKGh3DWKySJvcs9tlUG87hlo7AvnMo9pwRS_Zz2CacQ-MKaXyDepk=.AQAB"
index a0969e1d7c49c03cc4aa0ec7c39b12778ae06934..0a2e91298155fb49d72d78a146b8436e45bb9a6c 100644 (file)
@@ -5,10 +5,10 @@
 defmodule Pleroma.Web.StreamerTest do
   use Pleroma.DataCase
 
-  alias Pleroma.Web.Streamer
   alias Pleroma.List
   alias Pleroma.User
   alias Pleroma.Web.CommonAPI
+  alias Pleroma.Web.Streamer
   import Pleroma.Factory
 
   test "it sends to public" do
index 0e554623c511e669bdc138678bcf1fa8e1acbc57..d154385a0a33889ee97914ce1b68fd92858457c3 100644 (file)
@@ -4,12 +4,12 @@
 
 defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
   use Pleroma.DataCase
-  alias Pleroma.User
   alias Pleroma.Activity
   alias Pleroma.Object
+  alias Pleroma.User
+  alias Pleroma.Web.ActivityPub.ActivityPub
   alias Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter
   alias Pleroma.Web.TwitterAPI.Representers.ObjectRepresenter
-  alias Pleroma.Web.ActivityPub.ActivityPub
   alias Pleroma.Web.TwitterAPI.UserView
   import Pleroma.Factory
 
@@ -101,10 +101,14 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
       recipients: to
     }
 
+    corndog_emojo = ~s(<img height="32px" width="32px" alt="2hu" title="2hu" src="corndog.png" />)
+
     expected_html =
-      "<p>2hu <img height=\"32px\" width=\"32px\" alt=\"2hu\" title=\"2hu\" src=\"corndog.png\" /></p>alert('YAY')Some <img height=\"32px\" width=\"32px\" alt=\"2hu\" title=\"2hu\" src=\"corndog.png\" /> content mentioning <a href=\"#{
-        mentioned_user.ap_id
-      }\">@shp</a>"
+      ~s(<p>2hu ) <>
+        corndog_emojo <>
+        ~s(</p>alert\('YAY'\)Some ) <>
+        corndog_emojo <>
+        ~s( content mentioning <a href=") <> mentioned_user.ap_id <> ~s(">@shp</a>)
 
     expected_status = %{
       "id" => activity.id,
index ce0812308ac5c80cb0a1015c6dde784d4682fcf4..1b810c9a0fe936633d2e5ea641359ebd9a51694b 100644 (file)
@@ -4,23 +4,23 @@
 
 defmodule Pleroma.Web.TwitterAPI.ControllerTest do
   use Pleroma.Web.ConnCase
-  alias Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter
+  alias Comeonin.Pbkdf2
+  alias Ecto.Changeset
+  alias Pleroma.Activity
   alias Pleroma.Builders.ActivityBuilder
   alias Pleroma.Builders.UserBuilder
+  alias Pleroma.Notification
+  alias Pleroma.Object
   alias Pleroma.Repo
-  alias Pleroma.Activity
   alias Pleroma.User
-  alias Pleroma.Object
-  alias Pleroma.Notification
   alias Pleroma.Web.ActivityPub.ActivityPub
+  alias Pleroma.Web.CommonAPI
   alias Pleroma.Web.OAuth.Token
   alias Pleroma.Web.TwitterAPI.Controller
-  alias Pleroma.Web.TwitterAPI.UserView
   alias Pleroma.Web.TwitterAPI.NotificationView
-  alias Pleroma.Web.CommonAPI
+  alias Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter
   alias Pleroma.Web.TwitterAPI.TwitterAPI
-  alias Comeonin.Pbkdf2
-  alias Ecto.Changeset
+  alias Pleroma.Web.TwitterAPI.UserView
 
   import Pleroma.Factory
   import Mock
@@ -490,7 +490,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
 
       response = json_response(conn, 200)
 
-      assert length(response) == 0
+      assert Enum.empty?(response)
     end
   end
 
index aa2a4d6508e633dbf0107d5bcd1ebd08f85a6285..c8dd3fd7ae26c7b742cb69d6579637f7b722bbaf 100644 (file)
@@ -4,15 +4,15 @@
 
 defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
   use Pleroma.DataCase
-  alias Pleroma.Web.TwitterAPI.TwitterAPI
-  alias Pleroma.Web.TwitterAPI.UserView
   alias Pleroma.Activity
-  alias Pleroma.User
   alias Pleroma.Object
   alias Pleroma.Repo
+  alias Pleroma.User
   alias Pleroma.UserInviteToken
   alias Pleroma.Web.ActivityPub.ActivityPub
   alias Pleroma.Web.TwitterAPI.ActivityView
+  alias Pleroma.Web.TwitterAPI.TwitterAPI
+  alias Pleroma.Web.TwitterAPI.UserView
 
   import Pleroma.Factory
 
@@ -472,6 +472,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
 
       # Also fetches the feed.
       # assert Activity.get_create_by_object_ap_id("tag:mastodon.social,2017-04-05:objectId=1641750:objectType=Status")
+      # credo:disable-for-previous-line Credo.Check.Readability.MaxLineLength
     end
   end
 end
index 0a5384f34b44b0d0f032b272a35fb21d10f7ae81..6f0786b1c03e054afb0d3056202c166d5dc648f3 100644 (file)
@@ -5,15 +5,15 @@
 defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do
   use Pleroma.DataCase
 
+  alias Pleroma.Activity
+  alias Pleroma.Repo
+  alias Pleroma.User
+  alias Pleroma.Web.ActivityPub.ActivityPub
   alias Pleroma.Web.CommonAPI
   alias Pleroma.Web.CommonAPI.Utils
   alias Pleroma.Web.TwitterAPI.ActivityView
-  alias Pleroma.Web.TwitterAPI.UserView
   alias Pleroma.Web.TwitterAPI.TwitterAPI
-  alias Pleroma.Repo
-  alias Pleroma.Activity
-  alias Pleroma.User
-  alias Pleroma.Web.ActivityPub.ActivityPub
+  alias Pleroma.Web.TwitterAPI.UserView
 
   import Pleroma.Factory
   import Tesla.Mock
index 3a67f72926c3e53296129f6ea0d93ada2e4ca2ae..6baeeaf635fa5664315387c13b5b78c47427e9fb 100644 (file)
@@ -5,14 +5,14 @@
 defmodule Pleroma.Web.TwitterAPI.NotificationViewTest do
   use Pleroma.DataCase
 
-  alias Pleroma.User
   alias Pleroma.Notification
-  alias Pleroma.Web.TwitterAPI.TwitterAPI
+  alias Pleroma.User
+  alias Pleroma.Web.ActivityPub.ActivityPub
+  alias Pleroma.Web.CommonAPI.Utils
+  alias Pleroma.Web.TwitterAPI.ActivityView
   alias Pleroma.Web.TwitterAPI.NotificationView
+  alias Pleroma.Web.TwitterAPI.TwitterAPI
   alias Pleroma.Web.TwitterAPI.UserView
-  alias Pleroma.Web.TwitterAPI.ActivityView
-  alias Pleroma.Web.CommonAPI.Utils
-  alias Pleroma.Web.ActivityPub.ActivityPub
 
   import Pleroma.Factory
 
index 114f24a1c5582a7e3784278c5bc574ff6e22c929..4e7f94795375cfd0ef79277d7002db52ca046c94 100644 (file)
@@ -6,8 +6,8 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
   use Pleroma.DataCase
 
   alias Pleroma.User
-  alias Pleroma.Web.TwitterAPI.UserView
   alias Pleroma.Web.CommonAPI.Utils
+  alias Pleroma.Web.TwitterAPI.UserView
 
   import Pleroma.Factory
 
index 87b01d89b5cba80b5a381eb0067ef41bf7272095..1e69ed01a38ec6eca84d22c6524aaf999ac5c0df 100644 (file)
@@ -5,10 +5,10 @@
 defmodule Pleroma.Web.Websub.WebsubControllerTest do
   use Pleroma.Web.ConnCase
   import Pleroma.Factory
-  alias Pleroma.Web.Websub.WebsubClientSubscription
   alias Pleroma.Activity
   alias Pleroma.Repo
   alias Pleroma.Web.Websub
+  alias Pleroma.Web.Websub.WebsubClientSubscription
 
   test "websub subscription request", %{conn: conn} do
     user = insert(:user)
index 9a9b9df02c0692a0f00d19c9877ade7d41c2123c..74386d7dbb98a149fbb8afa1d2e3106782c79d28 100644 (file)
@@ -4,11 +4,13 @@
 
 defmodule Pleroma.Web.WebsubTest do
   use Pleroma.DataCase
+
+  alias Pleroma.Web.Router.Helpers
   alias Pleroma.Web.Websub
-  alias Pleroma.Web.Websub.WebsubServerSubscription
   alias Pleroma.Web.Websub.WebsubClientSubscription
+  alias Pleroma.Web.Websub.WebsubServerSubscription
+
   import Pleroma.Factory
-  alias Pleroma.Web.Router.Helpers
   import Tesla.Mock
 
   setup do