From 5a909e1bf06a5940089140fd96e07d2f49c4dec5 Mon Sep 17 00:00:00 2001 From: Ilja Date: Thu, 24 Sep 2020 13:10:56 +0200 Subject: [PATCH] Write better code --- lib/pleroma/config/deprecation_warnings.ex | 7 +++++-- test/config/deprecation_warnings_test.exs | 1 - 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/pleroma/config/deprecation_warnings.ex b/lib/pleroma/config/deprecation_warnings.ex index df41b0441..5ce545959 100644 --- a/lib/pleroma/config/deprecation_warnings.ex +++ b/lib/pleroma/config/deprecation_warnings.ex @@ -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 diff --git a/test/config/deprecation_warnings_test.exs b/test/config/deprecation_warnings_test.exs index ff230db05..b85f903e5 100644 --- a/test/config/deprecation_warnings_test.exs +++ b/test/config/deprecation_warnings_test.exs @@ -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!!!