Write better code

This commit is contained in:
Ilja 2020-09-24 13:10:56 +02:00
parent 90a97dfc37
commit 5a909e1bf0
2 changed files with 5 additions and 3 deletions

View File

@ -23,7 +23,10 @@ defmodule Pleroma.Config.DeprecationWarnings do
def check_simple_policy_tuples do
has_strings =
Config.get([:mrf_simple])
|> Enum.map(fn {_, v} -> v == [] || Enum.max(v) end)
|> Enum.map(fn
{_, []} -> {}
{_, v} -> Enum.max(v)
end)
|> Enum.max()
|> is_binary
@ -76,7 +79,7 @@ defmodule Pleroma.Config.DeprecationWarnings do
Config.put([:mrf_simple], new_config)
:ok
:error
else
:ok
end

View File

@ -22,7 +22,6 @@ defmodule Pleroma.Config.DeprecationWarningsTest do
reject_deletes: ["some.reject.deletes"]
)
# TODO: Can I take the actual config and new config instead? Note that it'll need to be clear where you put the reason.
assert capture_log(fn -> DeprecationWarnings.check_simple_policy_tuples() end) =~
"""
!!!DEPRECATION WARNING!!!