refactor: Replace length/1 with empty list comparison

Replace expensive length/1 calls with direct list comparison
to fix Credo warnings about performance
This commit is contained in:
Moritz 2026-01-20 15:58:15 +01:00
parent 32e0adb664
commit 0abcf540bb
2 changed files with 2 additions and 2 deletions

View file

@ -403,7 +403,7 @@ defmodule MvWeb.MemberLive.Form do
# Checks if form has any errors
defp has_form_errors?(form) do
case Map.get(form, :errors) do
errors when is_list(errors) and length(errors) > 0 -> true
errors when is_list(errors) and errors != [] -> true
_ -> false
end
end

View file

@ -404,7 +404,7 @@ defmodule Mv.Membership.Import.MemberCSVTest do
assert chunk_result.inserted == 0
assert chunk_result.failed == 10
assert length(chunk_result.errors) == 0
assert chunk_result.errors == []
end
test "error capping with mixed success and failure" do