[Credo] fix Credo.Check.Readability.MaxLineLength
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Tue, 5 Mar 2019 04:37:33 +0000 (05:37 +0100)
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Wed, 13 Mar 2019 03:26:56 +0000 (04:26 +0100)
17 files changed:
lib/pleroma/captcha/captcha.ex
lib/pleroma/clippy.ex
lib/pleroma/formatter.ex
lib/pleroma/plugs/oauth_plug.ex
lib/pleroma/reverse_proxy.ex
lib/pleroma/uploaders/s3.ex
lib/pleroma/user.ex
lib/pleroma/web/activity_pub/activity_pub.ex
lib/pleroma/web/activity_pub/mrf/keyword_policy.ex
lib/pleroma/web/controller_helper.ex
lib/pleroma/web/endpoint.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/push/subscription.ex
test/web/instances/instances_test.exs
test/web/twitter_api/twitter_api_test.exs

index cecb5b5a786e1b9d0b7314fdaf43ca62e4ebe3c6..f105cbb2529bc97a1ad42c6f37de050ddc546044 100644 (file)
@@ -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")
 
     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])
     # 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 1a1606a23fc06abded914b92442f01c02a2a607e..bd20952a6952a4c6ee130b620097bd23bb66ae99 100644 (file)
@@ -92,8 +92,8 @@ defmodule Pleroma.Clippy do
 
     # surrond one/five line clippy with blank lines around to not fuck up the layout
     #
 
     # 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 ++ [""]
     lines =
       if length(lines) == 1 or length(lines) == 5 do
         [""] ++ lines ++ [""]
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
 
   @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,
 
   @auto_linker_config hashtag: true,
                       hashtag_handler: &Pleroma.Formatter.hashtag_handler/4,
index 6130c457055efe3a67953566daa8ea55948c369f..5888d596aaaf4ae89df271be0166eabb13b75152 100644 (file)
@@ -38,6 +38,7 @@ defmodule Pleroma.Plugs.OAuthPlug do
         preload: [user: user]
       )
 
         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
     with %Token{user: %{info: %{deactivated: false} = _} = user} = token_record <- Repo.one(query) do
       {:ok, user, token_record}
     end
index a25b5ea4e16f0af9c804d65a53a4fd4a7afd3fd4..6298b92f4e4c12ceb4b17feebfde431ee5a747e1 100644 (file)
@@ -3,10 +3,12 @@
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.ReverseProxy do
 # 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 ++
   @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)
   @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? ->
         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 ->
         List.keystore(headers, "cache-control", 0, {"cache-control", "public"})
 
       true ->
index 0038ba01fdc0104bf3f06df637be60ed985ddc12..e7de3f3e0de84da366987a3b0a89ca9429080c20 100644 (file)
@@ -6,7 +6,8 @@ defmodule Pleroma.Uploaders.S3 do
   @behaviour Pleroma.Uploaders.Uploader
   require Logger
 
   @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)
   def get_file(file) do
     config = Pleroma.Config.get([__MODULE__])
     bucket = Keyword.fetch!(config, :bucket)
index dbb568ca0888fb0d3d699ba28d7bf80cd09f9645..1ce9882f63b6125c82c947dd16a47f3e55342f34 100644 (file)
@@ -30,6 +30,7 @@ defmodule Pleroma.User do
 
   @primary_key {:id, Pleroma.FlakeId, autogenerate: true}
 
 
   @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]+$/
   @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]+$/
@@ -435,7 +436,8 @@ defmodule Pleroma.User do
     Repo.get_by(User, ap_id: ap_id)
   end
 
     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, "/"))
   def get_by_guessed_nickname(ap_id) do
     domain = URI.parse(ap_id).host
     name = List.last(String.split(ap_id, "/"))
index 337dc0173ad4e42812bb9cfd6243bb67a3dbd549..fb8fe1ca293413afb50f2e3b2771a6d96ec1d8de 100644 (file)
@@ -170,7 +170,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
              additional
            ),
          {:ok, activity} <- insert(create_data, local),
              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}
          {: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),
            "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}
          {:ok, _actor} <- decrease_note_count_if_public(user, object),
          :ok <- maybe_federate(activity) do
       {:ok, activity}
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} =
 
   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
 
     {:ok,
      message
index 5915ea40e76730ceaa8bb233b29ced4939312fca..4d6192db03edb5f63eb8bbbc66078c0cb20d5792 100644 (file)
@@ -6,7 +6,8 @@ defmodule Pleroma.Web.ControllerHelper do
   use Pleroma.Web, :controller
 
   def oauth_scopes(params, default) 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
 
     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)
     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
   )
 
   # Code reloading can be explicitly enabled under the
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]
 
     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.
       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
 
           # 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" ->
               [
           case media_type do
             "audio" ->
               [
index a0be383e58b70d1de05424577bcd6b00f9e77777..040b872e7034d840705ffb324628d223a9f197b3 100644 (file)
@@ -97,7 +97,8 @@ defmodule Pleroma.Web.Metadata.Providers.TwitterCard do
                 | acc
               ]
 
                 | 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"], []},
             "video" ->
               [
                 {:meta, [property: "twitter:card", content: "player"], []},
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.
   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("+", "-")
   defp ensure_base64_urlsafe(string) do
     string
     |> String.replace("+", "-")
index 2530c09fe8fd20a0594cadf5526e609532bdb203..f0d84edeadf7d38af19b46eb750745d65368cd11 100644 (file)
@@ -102,7 +102,8 @@ defmodule Pleroma.InstancesTest do
     end
   end
 
     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)
   describe "set_unreachable/1" do
     test "returns error status on non-binary input" do
       assert {:error, _} = Instances.set_unreachable(nil)
index 1eb8f77d220d131f7534160918d8af12a27ee25d..c8dd3fd7ae26c7b742cb69d6579637f7b722bbaf 100644 (file)
@@ -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")
 
       # 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
     end
   end
 end