fix: replace cond blocks with pattern matching and case (CSM-021)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-11 09:04:56 +02:00
parent d231f42363
commit 2be43ca06d
4 changed files with 38 additions and 22 deletions

View File

@@ -62,14 +62,12 @@ defmodule BDS.AI do
model = get_setting("ai.#{kind_key}.model")
encrypted_api_key = get_setting(encrypted_key("ai.#{kind_key}.api_key"))
cond do
is_nil(url) and is_nil(model) and is_nil(encrypted_api_key) ->
{:ok, nil}
true ->
with {:ok, api_key} <- get_secret(encrypted_api_key, backend) do
{:ok, %{kind: kind, url: url, api_key: api_key, model: model}}
end
if is_nil(url) and is_nil(model) and is_nil(encrypted_api_key) do
{:ok, nil}
else
with {:ok, api_key} <- get_secret(encrypted_api_key, backend) do
{:ok, %{kind: kind, url: url, api_key: api_key, model: model}}
end
end
end