Fix credo style reports following it's update

Mainly transform `with` into `case`

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2019-07-23 18:06:22 +02:00
parent 1cd511f440
commit c3cca5d613
26 changed files with 303 additions and 248 deletions

View File

@@ -7,60 +7,60 @@ defmodule MobilizonWeb.FeedController do
action_fallback(MobilizonWeb.FallbackController)
def actor(conn, %{"name" => name, "format" => "atom"}) do
with {status, data} when status in [:ok, :commit] <-
Cachex.fetch(:feed, "actor_" <> name) do
conn
|> put_resp_content_type("application/atom+xml")
|> send_resp(200, data)
else
case Cachex.fetch(:feed, "actor_" <> name) do
{status, data} when status in [:ok, :commit] ->
conn
|> put_resp_content_type("application/atom+xml")
|> send_resp(200, data)
_err ->
{:error, :not_found}
end
end
def actor(conn, %{"name" => name, "format" => "ics"}) do
with {status, data} when status in [:ok, :commit] <-
Cachex.fetch(:ics, "actor_" <> name) do
conn
|> put_resp_content_type("text/calendar")
|> send_resp(200, data)
else
case Cachex.fetch(:ics, "actor_" <> name) do
{status, data} when status in [:ok, :commit] ->
conn
|> put_resp_content_type("text/calendar")
|> send_resp(200, data)
_err ->
{:error, :not_found}
end
end
def event(conn, %{"uuid" => uuid, "format" => "ics"}) do
with {status, data} when status in [:ok, :commit] <-
Cachex.fetch(:ics, "event_" <> uuid) do
conn
|> put_resp_content_type("text/calendar")
|> send_resp(200, data)
else
case Cachex.fetch(:ics, "event_" <> uuid) do
{status, data} when status in [:ok, :commit] ->
conn
|> put_resp_content_type("text/calendar")
|> send_resp(200, data)
_err ->
{:error, :not_found}
end
end
def going(conn, %{"token" => token, "format" => "ics"}) do
with {status, data} when status in [:ok, :commit] <-
Cachex.fetch(:ics, "token_" <> token) do
conn
|> put_resp_content_type("text/calendar")
|> send_resp(200, data)
else
case Cachex.fetch(:ics, "token_" <> token) do
{status, data} when status in [:ok, :commit] ->
conn
|> put_resp_content_type("text/calendar")
|> send_resp(200, data)
_err ->
{:error, :not_found}
end
end
def going(conn, %{"token" => token, "format" => "atom"}) do
with {status, data} when status in [:ok, :commit] <-
Cachex.fetch(:feed, "token_" <> token) do
conn
|> put_resp_content_type("application/atom+xml")
|> send_resp(200, data)
else
case Cachex.fetch(:feed, "token_" <> token) do
{status, data} when status in [:ok, :commit] ->
conn
|> put_resp_content_type("application/atom+xml")
|> send_resp(200, data)
_err ->
{:error, :not_found}
end