Skip to content

Commit 4b30417

Browse files
authored
fix: reduce warnings when running tests (#1270)
* replace warn with warning "warning: the log level :warn is deprecated, use :warning instead" * empty doc "warning: module attribute @doc was set but no definition follows it" * replace '' with "" "warning: using single-quoted strings to represent charlists is deprecated." * move function "clauses with the same name and arity (number of arguments) should be grouped together" * make range explicit "10..0 has a default step of -1, please write 10..0//-1 instead" * remove alias "unused alias" * rename unused variables "warning: variable "XXX" is unused" * remove choices from validate_required """ warning: attempting to determine the presence of embed_many field :choices with validate_required/3 ... which has no effect. You can pass the :required option to Ecto.Changeset.cast_embed/3 to achieve this. """ * delete unused variables instead * Revert "remove choices from validate_required" This reverts commit 088fa96.
1 parent 41026f5 commit 4b30417

File tree

11 files changed

+20
-26
lines changed

11 files changed

+20
-26
lines changed

config/test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ config :cadet, CadetWeb.Endpoint,
99
config :cadet, environment: :test
1010

1111
# Print only warnings and errors during test
12-
config :logger, level: :warn, compile_time_purge_matching: [[level_lower_than: :warn]]
12+
config :logger, level: :warning, compile_time_purge_matching: [[level_lower_than: :warning]]
1313

1414
config :ex_aws,
1515
access_key_id: "hello",

lib/cadet/accounts/teams.ex

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ defmodule Cadet.Accounts.Teams do
6464

6565
true ->
6666
Enum.reduce_while(attrs["student_ids"], {:ok, nil}, fn team_attrs, {:ok, _} ->
67-
student_ids = Enum.map(team_attrs, &Map.get(&1, "userId"))
68-
6967
{:ok, team} =
7068
%Team{}
7169
|> Team.changeset(attrs)
@@ -105,7 +103,6 @@ defmodule Cadet.Accounts.Teams do
105103
ids = Enum.map(team, &Map.get(&1, "userId"))
106104

107105
unique_ids_count = ids |> Enum.uniq() |> Enum.count()
108-
all_ids_distinct = unique_ids_count == Enum.count(ids)
109106

110107
student_already_in_team?(-1, ids, assessment_id)
111108
end)
@@ -229,7 +226,6 @@ defmodule Cadet.Accounts.Teams do
229226
230227
"""
231228
def update_team(team = %Team{}, new_assessment_id, student_ids) do
232-
old_assessment_id = team.assessment_id
233229
team_id = team.id
234230
new_student_ids = Enum.map(hd(student_ids), fn student -> Map.get(student, "userId") end)
235231

lib/cadet/devices/devices.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ defmodule Cadet.Devices do
212212
},
213213
300,
214214
[],
215-
''
215+
""
216216
)
217217

218218
# ExAws includes the session token in the signed payload and doesn't allow

lib/cadet/jobs/autograder/lambda_worker.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ defmodule Cadet.Autograder.LambdaWorker do
2121
lambda_params = build_request_params(params)
2222

2323
if Enum.empty?(lambda_params.testcases) do
24-
Logger.warn("No testcases found. Skipping autograding for answer_id: #{answer.id}")
24+
Logger.warning("No testcases found. Skipping autograding for answer_id: #{answer.id}")
2525
# Fix for https://github.com/source-academy/backend/issues/472
2626
Process.sleep(1000)
2727
else

lib/cadet/jobs/xml_parser.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ defmodule Cadet.Updater.XMLParser do
3434
:ok
3535
else
3636
{:error, stage, %{errors: [assessment: {"has submissions", []}]}, _} when is_atom(stage) ->
37-
Logger.warn("Assessment has submissions, ignoring...")
37+
Logger.warning("Assessment has submissions, ignoring...")
3838
{:ok, "Assessment has submissions, ignoring..."}
3939

4040
{:error, error_message} ->

lib/cadet/notifications.ex

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -276,15 +276,15 @@ defmodule Cadet.Notifications do
276276
|> Repo.insert()
277277
end
278278

279-
@doc """
280-
Returns the list of sent_notifications.
279+
# @doc """
280+
# Returns the list of sent_notifications.
281281

282-
## Examples
282+
# ## Examples
283283

284-
iex> list_sent_notifications()
285-
[%SentNotification{}, ...]
284+
# iex> list_sent_notifications()
285+
# [%SentNotification{}, ...]
286286

287-
"""
287+
# """
288288

289289
# def list_sent_notifications do
290290
# Repo.all(SentNotification)

lib/cadet_web/admin_controllers/admin_stories_controller.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ defmodule CadetWeb.AdminStoriesController do
1212

1313
case result do
1414
{:ok, _story} ->
15-
conn |> put_status(200) |> text('')
15+
conn |> put_status(200) |> text("")
1616

1717
{:error, {status, message}} ->
1818
conn
@@ -29,7 +29,7 @@ defmodule CadetWeb.AdminStoriesController do
2929

3030
case result do
3131
{:ok, _story} ->
32-
conn |> put_status(200) |> text('')
32+
conn |> put_status(200) |> text("")
3333

3434
{:error, {status, message}} ->
3535
conn
@@ -43,7 +43,7 @@ defmodule CadetWeb.AdminStoriesController do
4343

4444
case result do
4545
{:ok, _nil} ->
46-
conn |> put_status(204) |> text('')
46+
conn |> put_status(204) |> text("")
4747

4848
{:error, {status, message}} ->
4949
conn

lib/cadet_web/controllers/answer_controller.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ defmodule CadetWeb.AnswerController do
3838
end
3939
end
4040

41+
def submit(conn, _params) do
42+
send_resp(conn, :bad_request, "Missing or invalid parameter(s)")
43+
end
44+
4145
def check_last_modified(conn, %{
4246
"questionid" => question_id,
4347
"lastModifiedAt" => last_modified_at
@@ -79,10 +83,6 @@ defmodule CadetWeb.AnswerController do
7983
end
8084
end
8185

82-
def submit(conn, _params) do
83-
send_resp(conn, :bad_request, "Missing or invalid parameter(s)")
84-
end
85-
8686
swagger_path :submit do
8787
post("/assessments/question/{questionId}/answer")
8888

test/cadet/assessments/assessments_test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2223,7 +2223,7 @@ defmodule Cadet.AssessmentsTest do
22232223

22242224
test "limit submisssions 2", %{
22252225
course_regs: %{avenger1_cr: avenger},
2226-
assessments: assessments
2226+
assessments: _assessments
22272227
} do
22282228
{_, res} =
22292229
Assessments.submissions_by_grader_for_index(avenger, %{
@@ -3142,7 +3142,7 @@ defmodule Cadet.AssessmentsTest do
31423142

31433143
defp expected_top_relative_scores(top_x, token_divider) do
31443144
# "return 0;" in the factory has 3 token
3145-
10..0
3145+
10..0//-1
31463146
|> Enum.to_list()
31473147
|> Enum.map(fn score -> 10 * score - :math.pow(2, 3 / token_divider) end)
31483148
|> Enum.take(top_x)

test/cadet_web/admin_controllers/admin_assessments_controller_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ defmodule CadetWeb.AdminAssessmentsControllerTest do
55
import Ecto.Query
66
import ExUnit.CaptureLog
77

8-
alias Cadet.{Assessments, Repo}
8+
alias Cadet.Repo
99
alias Cadet.Accounts.CourseRegistration
1010
alias Cadet.Assessments.{Assessment, Submission}
1111
alias Cadet.Test.XMLGenerator

0 commit comments

Comments
 (0)