Skip to content

Commit 9112f4e

Browse files
committed
Fix credo
1 parent 38bf8fa commit 9112f4e

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

services/app/apps/codebattle/lib/codebattle/tournament/season_tournament_generator.ex

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -335,26 +335,22 @@ defmodule Codebattle.Tournament.SeasonTournamentGenerator do
335335
end_month = {end_date.year, end_date.month}
336336

337337
start_month
338-
|> Stream.unfold(fn {year, month} ->
339-
current = {year, month}
340-
341-
if compare_year_month(current, end_month) == :gt do
342-
nil
343-
else
344-
# credo:disable-for-next-line
345-
next =
346-
if month == 12 do
347-
{year + 1, 1}
348-
else
349-
{year, month + 1}
350-
end
351-
352-
{current, next}
353-
end
354-
end)
338+
|> Stream.unfold(&unfold_months(&1, end_month))
355339
|> Enum.to_list()
356340
end
357341

342+
defp unfold_months({year, month} = current, end_month) do
343+
if compare_year_month(current, end_month) == :gt do
344+
nil
345+
else
346+
next = next_month(year, month)
347+
{current, next}
348+
end
349+
end
350+
351+
defp next_month(year, 12), do: {year + 1, 1}
352+
defp next_month(year, month), do: {year, month + 1}
353+
358354
defp compare_year_month({y1, m1}, {y2, m2}) do
359355
cond do
360356
y1 < y2 -> :lt

0 commit comments

Comments
 (0)