Repository: etcd-io/etcd (language: go)

Issue:
Enable testifylint linter rules
### What would you like to be added?

This issue formalizes @mmorel-35's work (thanks!) to enable the linter rules from the `testifylint` linter.

The completion track is as follows:
- [x] bool-compare
  - [x] #18686 
  - [x] #18717
- [x] compares - #18715
- [x] empty - #18712
- [x] error-is-as - #18740
- [x] error-nil - #18716
- [x] expected-actual - #18720
- [x] float-compare - #18776
- [x] formatter - #18741
- [ ] go-require - #18827
- [x] len - #18712
- [x] negative-positive - #18715 
- [x] nil-compare
  - [x] #18689 
  - [x] #18717
- [x] require-error
  - [x] #18800
  - [x] #18814

### Why is this needed?

To improve the code quality.


Discussion / hints:
Hey @ivanvc, do you need some help here? I could take on a few items on the list if you want me to. Just let me know which are the preferred ones.
Thank you
Hi @ghouscht, thanks for offering your help with this task. Although it's unassigned (because I can't assign it to people outside of the etcd-io organization if they haven't participated in the issue), @mmorel-35 is doing it.

Therefore, I'm going to redirect the question. @mmorel-35, is there anything that @ghouscht could do to help with this task? Thanks.
We actually have two open PR for this linter so until they are merged you can start with the `error-is-as` or `formatter` with `formatter.require-f-funcs` option enabled. Keep your PR as draft until one of them is merged so the number of opened PR stay narrowed concerning testifylint.

You can configure it with https://golangci-lint.run/usage/linters/#testifylint

Golangci lint can not fix it with `--fix`. You can use testifylint with `-fix` to start fixing it then review the changes to see if everthing works correctly.
Thank you for the response @mmorel-35, I found some time today and opened two PRs for the `error-is-as` and `formatter` rules:

- https://github.com/etcd-io/etcd/pull/18740
- https://github.com/etcd-io/etcd/pull/18741

I also tagged you on the PRs (sorry for the spam 🙂). 
/assign @mmorel-35 @ghouscht 
Just curious - we should compare the `make verify` runtime before enabling these checks and now to make sure we aren't increasing test runtimes too significantly.

@mmorel-35 - As you have enabled these linter rules have you noticed any meaningful increase in test runtimes in CI or locally?
I haven't noticed any significant increase. What make you think there could be regarding the nature of changes that has been done yet ?
Running `make verify-lint` yields the following runtime on my machine

with a clean golangci-lint cache:
- with testifylint `21.941s` 
- without `20.632s` 

with golangci-lint cache present:
- with testifylint `4.926s` 
- without `4.947s`

I'd say that is neglible 🙂 

Fix patch:
diff --git a/tools/.golangci.yaml b/tools/.golangci.yaml
index 7752c115658..e032636313a 100644
--- a/tools/.golangci.yaml
+++ b/tools/.golangci.yaml
@@ -112,8 +112,6 @@ linters-settings: # please keep this alphabetized
     checks:
       - ST1019 # Importing the same package multiple times.
   testifylint:
-    disable:
-      - go-require
     enable-all: true
     formatter:
       # Require f-assertions (e.g. assert.Equalf) if a message is passed to the assertion, even if


Test patch:
diff --git a/tests/common/auth_test.go b/tests/common/auth_test.go
index afeca9245c6..3b0bcf71040 100644
--- a/tests/common/auth_test.go
+++ b/tests/common/auth_test.go
@@ -21,6 +21,7 @@ import (
 	"testing"
 	"time"
 
+	"github.com/stretchr/testify/assert"
 	"github.com/stretchr/testify/require"
 
 	clientv3 "go.etcd.io/etcd/client/v3"
@@ -110,7 +111,7 @@ func TestAuthGracefulDisable(t *testing.T) {
 				return
 			}
 			// the watcher should still work after reconnecting
-			require.NoErrorf(t, rootAuthClient.Put(ctx, "key", "value", config.PutOptions{}), "failed to put key value")
+			assert.NoErrorf(t, rootAuthClient.Put(ctx, "key", "value", config.PutOptions{}), "failed to put key value")
 		}()
 
 		wCtx, wCancel := context.WithCancel(ctx)
diff --git a/tests/e2e/corrupt_test.go b/tests/e2e/corrupt_test.go
index 27480f8f9c8..db5aaac318d 100644
--- a/tests/e2e/corrupt_test.go
+++ b/tests/e2e/corrupt_test.go
@@ -424,7 +424,7 @@ func testCtlV3ReadAfterWrite(t *testing.T, ops ...clientv3.OpOption) {
 			}
 
 			count++
-			require.Equal(t, "bar2", string(resp.Kvs[0].Value))
+			assert.Equal(t, "bar2", string(resp.Kvs[0].Value))
 		}
 	}()
 
diff --git a/tests/e2e/ctl_v3_member_test.go b/tests/e2e/ctl_v3_member_test.go
index 6c1a06c10b6..ffcd598ee18 100644
--- a/tests/e2e/ctl_v3_member_test.go
+++ b/tests/e2e/ctl_v3_member_test.go
@@ -107,7 +107,7 @@ func TestCtlV3ConsistentMemberList(t *testing.T) {
 			}
 
 			merr := epc.Procs[0].Restart(ctx)
-			require.NoError(t, merr)
+			assert.NoError(t, merr)
 			epc.WaitLeader(t)
 
 			time.Sleep(100 * time.Millisecond)
@@ -135,7 +135,7 @@ func TestCtlV3ConsistentMemberList(t *testing.T) {
 			}
 
 			count++
-			require.Len(t, mresp.Members, 1)
+			assert.Len(t, mresp.Members, 1)
 		}
 	}()
 
diff --git a/tests/e2e/v3_lease_no_proxy_test.go b/tests/e2e/v3_lease_no_proxy_test.go
index d7f44f1e4fc..2131c914fa5 100644
--- a/tests/e2e/v3_lease_no_proxy_test.go
+++ b/tests/e2e/v3_lease_no_proxy_test.go
@@ -21,6 +21,7 @@ import (
 	"testing"
 	"time"
 
+	"github.com/stretchr/testify/assert"
 	"github.com/stretchr/testify/require"
 
 	clientv3 "go.etcd.io/etcd/client/v3"
@@ -106,7 +107,7 @@ func testLeaseRevokeIssue(t *testing.T, clusterSize int, connectToOneFollower bo
 		defer close(doneC)
 
 		respC, kerr := clientForKeepAlive.KeepAlive(ctx, leaseRsp.ID)
-		require.NoError(t, kerr)
+		assert.NoError(t, kerr)
 		// ensure we have received the first response from the server
 		<-respC
 		startC <- struct{}{}
diff --git a/tests/e2e/watch_test.go b/tests/e2e/watch_test.go
index f3fb81f3cba..f167b8f8752 100644
--- a/tests/e2e/watch_test.go
+++ b/tests/e2e/watch_test.go
@@ -387,7 +387,7 @@ func testStartWatcherFromCompactedRevision(t *testing.T, performCompactOnTombsto
 				t.Logf("DELETE key=%s", key)
 
 				resp, derr := c.KV.Delete(ctx, key)
-				require.NoError(t, derr)
+				assert.NoError(t, derr)
 				respHeader = resp.Header
 
 				requestedValues = append(requestedValues, valueEvent{value: "", typ: mvccpb.DELETE})
@@ -396,7 +396,7 @@ func testStartWatcherFromCompactedRevision(t *testing.T, performCompactOnTombsto
 
 				t.Logf("PUT key=%s, val=%s", key, value)
 				resp, perr := c.KV.Put(ctx, key, value)
-				require.NoError(t, perr)
+				assert.NoError(t, perr)
 				respHeader = resp.Header
 
 				requestedValues = append(requestedValues, valueEvent{value: value, typ: mvccpb.PUT})
@@ -409,7 +409,7 @@ func testStartWatcherFromCompactedRevision(t *testing.T, performCompactOnTombsto
 
 				t.Logf("COMPACT rev=%d", lastRevision)
 				_, err = c.KV.Compact(ctx, lastRevision, clientv3.WithCompactPhysical())
-				require.NoError(t, err)
+				assert.NoError(t, err)
 			}
 		}
 	}()
diff --git a/tests/e2e/zap_logging_test.go b/tests/e2e/zap_logging_test.go
index d2598fad5b9..9596ba30882 100644
--- a/tests/e2e/zap_logging_test.go
+++ b/tests/e2e/zap_logging_test.go
@@ -20,6 +20,7 @@ import (
 	"testing"
 	"time"
 
+	"github.com/stretchr/testify/assert"
 	"github.com/stretchr/testify/require"
 
 	"go.etcd.io/etcd/tests/v3/framework/e2e"
@@ -130,7 +131,7 @@ func TestConnectionRejectMessage(t *testing.T) {
 			go func() {
 				startedCh <- struct{}{}
 				verr := e2e.WaitReadyExpectProc(context.TODO(), p, []string{tc.expectedErrMsg})
-				require.NoError(t, verr)
+				assert.NoError(t, verr)
 				doneCh <- struct{}{}
 			}()
 
diff --git a/tests/framework/testutils/log_observer_test.go b/tests/framework/testutils/log_observer_test.go
index 36ee2e7650c..695caf97261 100644
--- a/tests/framework/testutils/log_observer_test.go
+++ b/tests/framework/testutils/log_observer_test.go
@@ -53,7 +53,7 @@ func TestLogObserver_Expect(t *testing.T) {
 		defer close(resCh)
 
 		res, err := logOb.Expect(ctx, t.Name(), 2)
-		require.NoError(t, err)
+		assert.NoError(t, err)
 		resCh <- res
 	}()