refactor(credo): Refactor to appease new credo checks (complexity and logging)

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2023-04-19 18:33:06 +02:00
parent 8141bb0acb
commit eda2761032
13 changed files with 169 additions and 132 deletions

View File

@@ -53,13 +53,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Comment do
current_ip,
user_agent
) do
case Comments.create_comment(args) do
{:ok, _, %CommentModel{} = comment} ->
{:ok, comment}
{:error, err} ->
{:error, err}
end
do_create_comment(args)
else
{:error,
dgettext(
@@ -80,6 +74,18 @@ defmodule Mobilizon.GraphQL.Resolvers.Comment do
{:error, dgettext("errors", "You are not allowed to create a comment if not connected")}
end
@spec do_create_comment(map()) ::
{:ok, CommentModel.t()} | {:error, :entity_tombstoned | atom() | Ecto.Changeset.t()}
defp do_create_comment(args) do
case Comments.create_comment(args) do
{:ok, _, %CommentModel{} = comment} ->
{:ok, comment}
{:error, err} ->
{:error, err}
end
end
@spec update_comment(any(), map(), Absinthe.Resolution.t()) ::
{:ok, CommentModel.t()} | {:error, :unauthorized | :not_found | any() | String.t()}
def update_comment(