Skip to content

Commit

Permalink
fix(warnings): resolve warnings caused by updating elixir
Browse files Browse the repository at this point in the history
  • Loading branch information
akinsey committed Nov 27, 2024
1 parent 519420c commit da80260
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 17 deletions.
2 changes: 0 additions & 2 deletions lib/epochtalk_server_web/controllers/image_reference.ex
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ defmodule EpochtalkServerWeb.Controllers.ImageReference do
# checksum <- Validate.cast(attrs, "checksum", :string, required: true),
file_type <- Validate.cast(attrs, "file_type", :string, required: true) do
%{length: length, type: file_type}
else
_ -> %{error: "Invalid attrs"}
end
end
end
5 changes: 2 additions & 3 deletions lib/epochtalk_server_web/controllers/mention.ex
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ defmodule EpochtalkServerWeb.Controllers.Mention do
pagination_data: data,
extended: extended
}),
else:
({:auth, nil} ->
ErrorHelpers.render_json_error(conn, 400, "Not logged in, cannot page mentions"))
else: ({:auth, nil} ->
ErrorHelpers.render_json_error(conn, 400, "Not logged in, cannot page mentions"))
end
end
3 changes: 0 additions & 3 deletions lib/epochtalk_server_web/controllers/post.ex
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,6 @@ defmodule EpochtalkServerWeb.Controllers.Post do
Validate.cast(attrs, "body", :string, required: true, max: post_max_length, min: 1),
parsed_body <- Parse.markdown(body) do
render(conn, :preview, %{parsed_body: parsed_body})
else
_ ->
ErrorHelpers.render_json_error(conn, 400, "Error, cannot generate preview")
end
end

Expand Down
9 changes: 6 additions & 3 deletions lib/epochtalk_server_web/controllers/preference.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ defmodule EpochtalkServerWeb.Controllers.Preference do
def preferences(conn, _attrs) do
with {:auth, %{} = user} <- {:auth, Guardian.Plug.current_resource(conn)},
do: render(conn, :preferences, preferences: Preference.by_user_id(user.id)),
else:
({:auth, nil} ->
ErrorHelpers.render_json_error(conn, 400, "Not logged in, cannot fetch preferences"))
else: ({:auth, nil} ->
ErrorHelpers.render_json_error(
conn,
400,
"Not logged in, cannot fetch preferences"
))
end
end
2 changes: 0 additions & 2 deletions lib/epochtalk_server_web/controllers/thread.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ defmodule EpochtalkServerWeb.Controllers.Thread do
user_priority <- ACL.get_user_priority(conn),
threads <- Thread.recent(user, user_priority) do
render(conn, :recent, %{threads: threads})
else
_ -> ErrorHelpers.render_json_error(conn, 400, "Error, cannot fetch recent threads")
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/epochtalk_server_web/json/thread_json.ex
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ defmodule EpochtalkServerWeb.Controllers.ThreadJSON do
# handle deleted user
thread =
if thread.user_deleted,
do: thread |> Map.put(:user_id, '') |> Map.put(:username, ''),
do: thread |> Map.put(:user_id, "") |> Map.put(:username, ""),
else: thread

# format user output
Expand Down
2 changes: 1 addition & 1 deletion test/epochtalk_server_web/controllers/post_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ defmodule Test.EpochtalkServerWeb.Controllers.Post do
fn ->
post(conn, Routes.post_path(conn, :preview), %{
"body" =>
for(_ <- 1..10_001, into: "", do: <<Enum.random('0123456789abcdef')>>)
for(_ <- 1..10_001, into: "", do: <<Enum.random(~c"0123456789abcdef")>>)
})
end
end
Expand Down
4 changes: 2 additions & 2 deletions test/epochtalk_server_web/controllers/user_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@ defmodule Test.EpochtalkServerWeb.Controllers.User do
end
end

@tag :banned
describe "unban/1" do
@tag :banned
test "unbans banned user", %{users: %{user: user}} do
{:ok, unbanned_user_changeset} = Ban.unban(user)
assert unbanned_user_changeset.ban_info == nil
end
end

@tag :malicious
describe "handle_malicious_user/2" do
@tag :malicious
test "populates ban_info and malicious_score if user is malicious", %{
users: %{user: user},
malicious_user_changeset: malicious_user_changeset
Expand Down

0 comments on commit da80260

Please sign in to comment.