Fix some credo issues

This commit is contained in:
Liam 2024-06-24 23:23:43 -04:00
parent dbbc067679
commit 1b020a4fe9
7 changed files with 16 additions and 14 deletions

11
.credo.exs Normal file
View file

@ -0,0 +1,11 @@
%{
configs: %{
name: "default",
checks: %{
disabled: [
{Credo.Check.Refactor.CondStatements, false},
{Credo.Check.Refactor.NegatedConditionsWithElse, false}
]
}
}
}

View file

@ -333,7 +333,7 @@ defmodule Philomena.Galleries do
end) end)
changes changes
|> Enum.map(fn change -> |> Enum.each(fn change ->
id = Keyword.fetch!(change, :id) id = Keyword.fetch!(change, :id)
change = Keyword.delete(change, :id) change = Keyword.delete(change, :id)

View file

@ -535,7 +535,6 @@ defmodule Philomena.Users.User do
"data:image/png;base64," <> png "data:image/png;base64," <> png
end end
@spec totp_secret(%Philomena.Users.User{}) :: binary()
def totp_secret(user) do def totp_secret(user) do
Philomena.Users.Encryptor.decrypt_model( Philomena.Users.Encryptor.decrypt_model(
user.encrypted_otp_secret, user.encrypted_otp_secret,

View file

@ -212,9 +212,7 @@ defmodule PhilomenaQuery.Parse.Parser do
end end
defp debug_tokens(tokens) do defp debug_tokens(tokens) do
tokens Enum.map_join(tokens, fn {_k, v} -> v end)
|> Enum.map(fn {_k, v} -> v end)
|> Enum.join("")
end end
# #

View file

@ -26,7 +26,6 @@ defmodule PhilomenaQuery.Parse.String do
str str
|> String.replace("\r", "") |> String.replace("\r", "")
|> String.split("\n", trim: true) |> String.split("\n", trim: true)
|> Enum.map(fn s -> "(#{s})" end) |> Enum.map_join(" || ", &"(#{&1})")
|> Enum.join(" || ")
end end
end end

View file

@ -37,10 +37,7 @@ defmodule PhilomenaWeb.ContentSecurityPolicyPlug do
{:media_src, ["'self'", "blob:", "data:", cdn_uri, camo_uri]} {:media_src, ["'self'", "blob:", "data:", cdn_uri, camo_uri]}
] ]
csp_value = csp_value = Enum.map_join(csp_config, "; ", &cspify_element/1)
csp_config
|> Enum.map(&cspify_element/1)
|> Enum.join("; ")
csp_relaxed? do csp_relaxed? do
if conn.status == 500 do if conn.status == 500 do

View file

@ -117,9 +117,7 @@ defmodule PhilomenaWeb.AppView do
def escape_nl2br(text) do def escape_nl2br(text) do
text text
|> String.split("\n") |> String.split("\n")
|> Enum.map(&html_escape/1) |> Enum.map_intersperse("<br />", &safe_to_string(html_escape(&1)))
|> Enum.map(&safe_to_string/1)
|> Enum.join("<br/>")
|> raw() |> raw()
end end