forked from AkkomaGang/akkoma
Better way of getting keys
I used keyword_list[:key], but if the key doesn't exist, it will return nil. I actually expect a list and further down the code I use that list. I believe the key should always be present, but in case it's not, it's better to return an empty list instead of nil. That way the code wont fail further down the line.
This commit is contained in:
parent
75ea766824
commit
81afaee374
2 changed files with 2 additions and 2 deletions
|
@ -21,7 +21,7 @@ defmodule Pleroma.Config.DeprecationWarnings do
|
|||
]
|
||||
|
||||
def check_exiftool_filter do
|
||||
filters = Config.get([Pleroma.Upload])[:filters]
|
||||
filters = Config.get([Pleroma.Upload]) |> Keyword.get(:filters, [])
|
||||
|
||||
if Pleroma.Upload.Filter.Exiftool in filters do
|
||||
Logger.warn("""
|
||||
|
|
|
@ -51,7 +51,7 @@ test "changes setting to exiftool strip location" do
|
|||
|
||||
capture_log(fn -> DeprecationWarnings.warn() end)
|
||||
|
||||
assert Config.get([Pleroma.Upload])[:filters] == expected_config
|
||||
assert Config.get([Pleroma.Upload]) |> Keyword.get(:filters, []) == expected_config
|
||||
end
|
||||
|
||||
test "doesn't give a warning with correct config" do
|
||||
|
|
Loading…
Reference in a new issue