Merge pull request #311 from philomena-dev/credo-efficiency

Fix some credo issues
This commit is contained in:
liamwhite 2024-06-25 17:35:30 -04:00 committed by GitHub
commit 8df91eff16
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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)
changes
|> Enum.map(fn change ->
|> Enum.each(fn change ->
id = Keyword.fetch!(change, :id)
change = Keyword.delete(change, :id)

View file

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

View file

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

View file

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

View file

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

View file

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