From 45df749200fc7de3379e25988b20d70dbdfb936e Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Thu, 19 Dec 2024 19:02:17 +0000 Subject: [PATCH] No need to create a range when total_pages is 0 Fixes: warning: Range.new/2 and first..last default to a step of -1 when last < first. Use Range.new(first, last, -1) or first..last//-1, or pass 1 if that was your intention --- lib/music_library_web/components/pagination.ex | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/music_library_web/components/pagination.ex b/lib/music_library_web/components/pagination.ex index cabc8e6b..962edbd1 100644 --- a/lib/music_library_web/components/pagination.ex +++ b/lib/music_library_web/components/pagination.ex @@ -212,7 +212,12 @@ defmodule MusicLibraryWeb.Pagination do } = pagination_params total_pages = total_pages(total_entries, page_size) - all_pages = Enum.to_list(1..total_pages) + + all_pages = + case total_pages do + 0 -> [] + other -> Enum.to_list(1..other) + end {left_pages, middle_pages, right_pages} = Enum.reduce(all_pages, {[], [], []}, fn p, {left_p, middle_p, right_p} ->