This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb.git


The following commit(s) were added to refs/heads/main by this push:
     new b0de5fa22 Fix Credo 1.7.14 ExpensiveEmptyEnumCheck warnings
b0de5fa22 is described below

commit b0de5fa2296c2194bb44bc94ac742d9ffa445f1d
Author: aman-ak-r <[email protected]>
AuthorDate: Tue Dec 2 01:27:52 2025 +0530

    Fix Credo 1.7.14 ExpensiveEmptyEnumCheck warnings
    
    Replace expensive length/1 checks with Enum.empty?/1 in test files
    to resolve Credo warnings introduced in version 1.7.14.
    
    Changes:
    - test/elixir/test/replication_test.exs: Replace length(list) > 0
    - test/elixir/lib/couch/dbtest.ex: Replace length(list) > 0
    - test/elixir/test/partition_size_limit_test.exs: Replace length(list) > 0
    - test/elixir/test/basics_test.exs: Replace length(list) >= 1
    
    These changes are semantically equivalent but more performant as
    Enum.empty?/1 only checks for the first element instead of
    traversing the entire list.
    
    Fixes #5799
---
 test/elixir/lib/couch/dbtest.ex                | 2 +-
 test/elixir/test/basics_test.exs               | 2 +-
 test/elixir/test/partition_size_limit_test.exs | 2 +-
 test/elixir/test/replication_test.exs          | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/test/elixir/lib/couch/dbtest.ex b/test/elixir/lib/couch/dbtest.ex
index 8a1a32449..b1ef926ab 100644
--- a/test/elixir/lib/couch/dbtest.ex
+++ b/test/elixir/lib/couch/dbtest.ex
@@ -196,7 +196,7 @@ defmodule Couch.DBTest do
           query: [feed: "longpoll", timeout: 5000, filter: "_design"]
         )
       results = resp.body["results"]
-      is_list(results) && length(results) > 0
+      is_list(results) && not Enum.empty?(results)
     end, 500, 60_000)
   end
 
diff --git a/test/elixir/test/basics_test.exs b/test/elixir/test/basics_test.exs
index 3c04ce8a2..21eb77bcf 100644
--- a/test/elixir/test/basics_test.exs
+++ b/test/elixir/test/basics_test.exs
@@ -64,7 +64,7 @@ defmodule BasicsTest do
     db_count = length(Couch.get("/_all_dbs").body)
     assert db_count > 0
     assert Couch.get("/_all_dbs?limit=0").body == []
-    assert length(Couch.get("/_all_dbs?limit=1").body) >= 1
+    assert not Enum.empty?(Couch.get("/_all_dbs?limit=1").body)
     assert length(Couch.get("/_all_dbs?skip=1").body) == (db_count - 1)
     assert [db] == Couch.get("/_all_dbs?start_key=\"#{db}\"&limit=1").body
   end
diff --git a/test/elixir/test/partition_size_limit_test.exs 
b/test/elixir/test/partition_size_limit_test.exs
index 6ef686611..de3d08c56 100644
--- a/test/elixir/test/partition_size_limit_test.exs
+++ b/test/elixir/test/partition_size_limit_test.exs
@@ -228,7 +228,7 @@ defmodule PartitionSizeLimitTest do
     assert resp.status_code in [200, 202]
     %{body: body} = resp
 
-    assert length(body["rows"]) > 0
+    assert not Enum.empty?(body["rows"])
   end
 
   test "purging docs allows writes", context do
diff --git a/test/elixir/test/replication_test.exs 
b/test/elixir/test/replication_test.exs
index f6658deed..315136324 100644
--- a/test/elixir/test/replication_test.exs
+++ b/test/elixir/test/replication_test.exs
@@ -1671,7 +1671,7 @@ defmodule ReplicationTest do
     revs_checked = task["revisions_checked"]
     changes = get_db_changes(src_db_name, %{:since => through_seq})
 
-    if length(changes["results"]) > 0 or revs_checked < expect_revs_checked do
+    if not Enum.empty?(changes["results"]) or revs_checked < 
expect_revs_checked do
       :timer.sleep(500)
       wait_for_repl(src_db_name, repl_id, expect_revs_checked, wait_left - 500)
     end

Reply via email to