Skip to content

Commit

Permalink
[chore]: enable compares and negative-positive rules from testifylint
Browse files Browse the repository at this point in the history
Signed-off-by: Matthieu MOREL <[email protected]>
  • Loading branch information
mmorel-35 committed Sep 10, 2024
1 parent 306a07a commit 67a68b1
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 134 deletions.
2 changes: 0 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,11 @@ linters-settings:
testifylint:
# TODO: enable all rules
disable:
- compares
- error-is-as
- expected-actual
- float-compare
- formatter
- go-require
- negative-positive
- require-error
enable-all: true

Expand Down
2 changes: 1 addition & 1 deletion Makefile.Common
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ SEMCONVGEN := $(TOOLS_BIN_DIR)/semconvgen
SEMCONVKIT := $(TOOLS_BIN_DIR)/semconvkit
TESTIFYLINT := $(TOOLS_BIN_DIR)/testifylint

TESTIFYLINT_OPT?= --enable-all --disable=compares,error-is-as,expected-actual,float-compare,formatter,go-require,negative-positive,require-error
TESTIFYLINT_OPT?= --enable-all --disable=error-is-as,expected-actual,float-compare,formatter,go-require,require-error

.PHONY: install-tools
install-tools: $(TOOLS_BIN_NAMES)
Expand Down
2 changes: 1 addition & 1 deletion exporter/exporterhelper/retry_sender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func TestQueuedRetry_ThrottleError(t *testing.T) {
ocs.awaitAsyncProcessing()

// The initial backoff is 10ms, but because of the throttle this should wait at least 100ms.
assert.True(t, 100*time.Millisecond < time.Since(start))
assert.Less(t, 100*time.Millisecond, time.Since(start))

mockR.checkNumRequests(t, 2)
ocs.checkSendItemsCount(t, 2)
Expand Down
64 changes: 32 additions & 32 deletions internal/fanoutconsumer/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@ func TestLogsMultiplexingNonMutating(t *testing.T) {
}
}

assert.True(t, ld == p1.AllLogs()[0])
assert.True(t, ld == p1.AllLogs()[1])
assert.Equal(t, ld, p1.AllLogs()[0])
assert.Equal(t, ld, p1.AllLogs()[1])
assert.EqualValues(t, ld, p1.AllLogs()[0])
assert.EqualValues(t, ld, p1.AllLogs()[1])

assert.True(t, ld == p2.AllLogs()[0])
assert.True(t, ld == p2.AllLogs()[1])
assert.Equal(t, ld, p2.AllLogs()[0])
assert.Equal(t, ld, p2.AllLogs()[1])
assert.EqualValues(t, ld, p2.AllLogs()[0])
assert.EqualValues(t, ld, p2.AllLogs()[1])

assert.True(t, ld == p3.AllLogs()[0])
assert.True(t, ld == p3.AllLogs()[1])
assert.Equal(t, ld, p3.AllLogs()[0])
assert.Equal(t, ld, p3.AllLogs()[1])
assert.EqualValues(t, ld, p3.AllLogs()[0])
assert.EqualValues(t, ld, p3.AllLogs()[1])

Expand All @@ -80,19 +80,19 @@ func TestLogsMultiplexingMutating(t *testing.T) {
}
}

assert.True(t, ld != p1.AllLogs()[0])
assert.True(t, ld != p1.AllLogs()[1])
assert.NotEqual(t, ld, p1.AllLogs()[0])
assert.NotEqual(t, ld, p1.AllLogs()[1])
assert.EqualValues(t, ld, p1.AllLogs()[0])
assert.EqualValues(t, ld, p1.AllLogs()[1])

assert.True(t, ld != p2.AllLogs()[0])
assert.True(t, ld != p2.AllLogs()[1])
assert.NotEqual(t, ld, p2.AllLogs()[0])
assert.NotEqual(t, ld, p2.AllLogs()[1])
assert.EqualValues(t, ld, p2.AllLogs()[0])
assert.EqualValues(t, ld, p2.AllLogs()[1])

// For this consumer, will receive the initial data.
assert.True(t, ld == p3.AllLogs()[0])
assert.True(t, ld == p3.AllLogs()[1])
assert.Equal(t, ld, p3.AllLogs()[0])
assert.Equal(t, ld, p3.AllLogs()[1])
assert.EqualValues(t, ld, p3.AllLogs()[0])
assert.EqualValues(t, ld, p3.AllLogs()[1])

Expand Down Expand Up @@ -121,18 +121,18 @@ func TestReadOnlyLogsMultiplexingMutating(t *testing.T) {

// All consumers should receive the cloned data.

assert.True(t, ld != p1.AllLogs()[0])
assert.True(t, ld != p1.AllLogs()[1])
assert.NotEqual(t, ld, p1.AllLogs()[0])
assert.NotEqual(t, ld, p1.AllLogs()[1])
assert.EqualValues(t, ldOrig, p1.AllLogs()[0])
assert.EqualValues(t, ldOrig, p1.AllLogs()[1])

assert.True(t, ld != p2.AllLogs()[0])
assert.True(t, ld != p2.AllLogs()[1])
assert.NotEqual(t, ld, p2.AllLogs()[0])
assert.NotEqual(t, ld, p2.AllLogs()[1])
assert.EqualValues(t, ldOrig, p2.AllLogs()[0])
assert.EqualValues(t, ldOrig, p2.AllLogs()[1])

assert.True(t, ld != p3.AllLogs()[0])
assert.True(t, ld != p3.AllLogs()[1])
assert.NotEqual(t, ld, p3.AllLogs()[0])
assert.NotEqual(t, ld, p3.AllLogs()[1])
assert.EqualValues(t, ldOrig, p3.AllLogs()[0])
assert.EqualValues(t, ldOrig, p3.AllLogs()[1])
}
Expand All @@ -154,20 +154,20 @@ func TestLogsMultiplexingMixLastMutating(t *testing.T) {
}
}

assert.True(t, ld != p1.AllLogs()[0])
assert.True(t, ld != p1.AllLogs()[1])
assert.NotEqual(t, ld, p1.AllLogs()[0])
assert.NotEqual(t, ld, p1.AllLogs()[1])
assert.EqualValues(t, ld, p1.AllLogs()[0])
assert.EqualValues(t, ld, p1.AllLogs()[1])

// For this consumer, will receive the initial data.
assert.True(t, ld == p2.AllLogs()[0])
assert.True(t, ld == p2.AllLogs()[1])
assert.Equal(t, ld, p2.AllLogs()[0])
assert.Equal(t, ld, p2.AllLogs()[1])
assert.EqualValues(t, ld, p2.AllLogs()[0])
assert.EqualValues(t, ld, p2.AllLogs()[1])

// For this consumer, will clone the initial data.
assert.True(t, ld != p3.AllLogs()[0])
assert.True(t, ld != p3.AllLogs()[1])
assert.NotEqual(t, ld, p3.AllLogs()[0])
assert.NotEqual(t, ld, p3.AllLogs()[1])
assert.EqualValues(t, ld, p3.AllLogs()[0])
assert.EqualValues(t, ld, p3.AllLogs()[1])

Expand All @@ -192,19 +192,19 @@ func TestLogsMultiplexingMixLastNonMutating(t *testing.T) {
}
}

assert.True(t, ld != p1.AllLogs()[0])
assert.True(t, ld != p1.AllLogs()[1])
assert.NotEqual(t, ld, p1.AllLogs()[0])
assert.NotEqual(t, ld, p1.AllLogs()[1])
assert.EqualValues(t, ld, p1.AllLogs()[0])
assert.EqualValues(t, ld, p1.AllLogs()[1])

assert.True(t, ld != p2.AllLogs()[0])
assert.True(t, ld != p2.AllLogs()[1])
assert.NotEqual(t, ld, p2.AllLogs()[0])
assert.NotEqual(t, ld, p2.AllLogs()[1])
assert.EqualValues(t, ld, p2.AllLogs()[0])
assert.EqualValues(t, ld, p2.AllLogs()[1])

// For this consumer, will receive the initial data.
assert.True(t, ld == p3.AllLogs()[0])
assert.True(t, ld == p3.AllLogs()[1])
assert.Equal(t, ld, p3.AllLogs()[0])
assert.Equal(t, ld, p3.AllLogs()[1])
assert.EqualValues(t, ld, p3.AllLogs()[0])
assert.EqualValues(t, ld, p3.AllLogs()[1])

Expand All @@ -224,8 +224,8 @@ func TestLogsWhenErrors(t *testing.T) {
assert.Error(t, lfc.ConsumeLogs(context.Background(), ld))
}

assert.True(t, ld == p3.AllLogs()[0])
assert.True(t, ld == p3.AllLogs()[1])
assert.Equal(t, ld, p3.AllLogs()[0])
assert.Equal(t, ld, p3.AllLogs()[1])
assert.EqualValues(t, ld, p3.AllLogs()[0])
assert.EqualValues(t, ld, p3.AllLogs()[1])
}
Expand Down
64 changes: 32 additions & 32 deletions internal/fanoutconsumer/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@ func TestMetricsMultiplexingNonMutating(t *testing.T) {
}
}

assert.True(t, md == p1.AllMetrics()[0])
assert.True(t, md == p1.AllMetrics()[1])
assert.Equal(t, md, p1.AllMetrics()[0])
assert.Equal(t, md, p1.AllMetrics()[1])
assert.EqualValues(t, md, p1.AllMetrics()[0])
assert.EqualValues(t, md, p1.AllMetrics()[1])

assert.True(t, md == p2.AllMetrics()[0])
assert.True(t, md == p2.AllMetrics()[1])
assert.Equal(t, md, p2.AllMetrics()[0])
assert.Equal(t, md, p2.AllMetrics()[1])
assert.EqualValues(t, md, p2.AllMetrics()[0])
assert.EqualValues(t, md, p2.AllMetrics()[1])

assert.True(t, md == p3.AllMetrics()[0])
assert.True(t, md == p3.AllMetrics()[1])
assert.Equal(t, md, p3.AllMetrics()[0])
assert.Equal(t, md, p3.AllMetrics()[1])
assert.EqualValues(t, md, p3.AllMetrics()[0])
assert.EqualValues(t, md, p3.AllMetrics()[1])

Expand All @@ -80,19 +80,19 @@ func TestMetricsMultiplexingMutating(t *testing.T) {
}
}

assert.True(t, md != p1.AllMetrics()[0])
assert.True(t, md != p1.AllMetrics()[1])
assert.NotEqual(t, md, p1.AllMetrics()[0])
assert.NotEqual(t, md, p1.AllMetrics()[1])
assert.EqualValues(t, md, p1.AllMetrics()[0])
assert.EqualValues(t, md, p1.AllMetrics()[1])

assert.True(t, md != p2.AllMetrics()[0])
assert.True(t, md != p2.AllMetrics()[1])
assert.NotEqual(t, md, p2.AllMetrics()[0])
assert.NotEqual(t, md, p2.AllMetrics()[1])
assert.EqualValues(t, md, p2.AllMetrics()[0])
assert.EqualValues(t, md, p2.AllMetrics()[1])

// For this consumer, will receive the initial data.
assert.True(t, md == p3.AllMetrics()[0])
assert.True(t, md == p3.AllMetrics()[1])
assert.Equal(t, md, p3.AllMetrics()[0])
assert.Equal(t, md, p3.AllMetrics()[1])
assert.EqualValues(t, md, p3.AllMetrics()[0])
assert.EqualValues(t, md, p3.AllMetrics()[1])

Expand Down Expand Up @@ -121,18 +121,18 @@ func TestReadOnlyMetricsMultiplexingMixFirstMutating(t *testing.T) {

// All consumers should receive the cloned data.

assert.True(t, md != p1.AllMetrics()[0])
assert.True(t, md != p1.AllMetrics()[1])
assert.NotEqual(t, md, p1.AllMetrics()[0])
assert.NotEqual(t, md, p1.AllMetrics()[1])
assert.EqualValues(t, mdOrig, p1.AllMetrics()[0])
assert.EqualValues(t, mdOrig, p1.AllMetrics()[1])

assert.True(t, md != p2.AllMetrics()[0])
assert.True(t, md != p2.AllMetrics()[1])
assert.NotEqual(t, md, p2.AllMetrics()[0])
assert.NotEqual(t, md, p2.AllMetrics()[1])
assert.EqualValues(t, mdOrig, p2.AllMetrics()[0])
assert.EqualValues(t, mdOrig, p2.AllMetrics()[1])

assert.True(t, md != p3.AllMetrics()[0])
assert.True(t, md != p3.AllMetrics()[1])
assert.NotEqual(t, md, p3.AllMetrics()[0])
assert.NotEqual(t, md, p3.AllMetrics()[1])
assert.EqualValues(t, mdOrig, p3.AllMetrics()[0])
assert.EqualValues(t, mdOrig, p3.AllMetrics()[1])
}
Expand All @@ -154,20 +154,20 @@ func TestMetricsMultiplexingMixLastMutating(t *testing.T) {
}
}

assert.True(t, md != p1.AllMetrics()[0])
assert.True(t, md != p1.AllMetrics()[1])
assert.NotEqual(t, md, p1.AllMetrics()[0])
assert.NotEqual(t, md, p1.AllMetrics()[1])
assert.EqualValues(t, md, p1.AllMetrics()[0])
assert.EqualValues(t, md, p1.AllMetrics()[1])

// For this consumer, will receive the initial data.
assert.True(t, md == p2.AllMetrics()[0])
assert.True(t, md == p2.AllMetrics()[1])
assert.Equal(t, md, p2.AllMetrics()[0])
assert.Equal(t, md, p2.AllMetrics()[1])
assert.EqualValues(t, md, p2.AllMetrics()[0])
assert.EqualValues(t, md, p2.AllMetrics()[1])

// For this consumer, will clone the initial data.
assert.True(t, md != p3.AllMetrics()[0])
assert.True(t, md != p3.AllMetrics()[1])
assert.NotEqual(t, md, p3.AllMetrics()[0])
assert.NotEqual(t, md, p3.AllMetrics()[1])
assert.EqualValues(t, md, p3.AllMetrics()[0])
assert.EqualValues(t, md, p3.AllMetrics()[1])

Expand All @@ -192,19 +192,19 @@ func TestMetricsMultiplexingMixLastNonMutating(t *testing.T) {
}
}

assert.True(t, md != p1.AllMetrics()[0])
assert.True(t, md != p1.AllMetrics()[1])
assert.NotEqual(t, md, p1.AllMetrics()[0])
assert.NotEqual(t, md, p1.AllMetrics()[1])
assert.EqualValues(t, md, p1.AllMetrics()[0])
assert.EqualValues(t, md, p1.AllMetrics()[1])

assert.True(t, md != p2.AllMetrics()[0])
assert.True(t, md != p2.AllMetrics()[1])
assert.NotEqual(t, md, p2.AllMetrics()[0])
assert.NotEqual(t, md, p2.AllMetrics()[1])
assert.EqualValues(t, md, p2.AllMetrics()[0])
assert.EqualValues(t, md, p2.AllMetrics()[1])

// For this consumer, will receive the initial data.
assert.True(t, md == p3.AllMetrics()[0])
assert.True(t, md == p3.AllMetrics()[1])
assert.Equal(t, md, p3.AllMetrics()[0])
assert.Equal(t, md, p3.AllMetrics()[1])
assert.EqualValues(t, md, p3.AllMetrics()[0])
assert.EqualValues(t, md, p3.AllMetrics()[1])

Expand All @@ -224,8 +224,8 @@ func TestMetricsWhenErrors(t *testing.T) {
assert.Error(t, mfc.ConsumeMetrics(context.Background(), md))
}

assert.True(t, md == p3.AllMetrics()[0])
assert.True(t, md == p3.AllMetrics()[1])
assert.Equal(t, md, p3.AllMetrics()[0])
assert.Equal(t, md, p3.AllMetrics()[1])
assert.EqualValues(t, md, p3.AllMetrics()[0])
assert.EqualValues(t, md, p3.AllMetrics()[1])
}
Expand Down
Loading

0 comments on commit 67a68b1

Please sign in to comment.