From d9fab9005d728ed988b0b6a0ccbf406c86df9b02 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Tue, 24 Sep 2024 20:10:10 +0200 Subject: [PATCH] [chore]: enable compares and negative-positive rules from testifylint (#6139) Testifylint is a linter that provides best practices with the use of testify. This PR enables [compares](https://github.com/Antonboom/testifylint?tab=readme-ov-file#compares) and [negative-positive](https://github.com/Antonboom/testifylint?tab=readme-ov-file#negative-positive) rules from [testifylint](https://github.com/Antonboom/testifylint) Signed-off-by: Matthieu MOREL --- .golangci.yml | 2 -- instrumentation/runtime/runtime_test.go | 2 +- propagators/b3/b3_propagator_test.go | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index f56613831e1..2ce610600a8 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -247,10 +247,8 @@ linters-settings: testifylint: enable-all: true disable: - - compares - expected-actual - float-compare - formatter - go-require - - negative-positive - require-error diff --git a/instrumentation/runtime/runtime_test.go b/instrumentation/runtime/runtime_test.go index 78b3b52b784..67df9768580 100644 --- a/instrumentation/runtime/runtime_test.go +++ b/instrumentation/runtime/runtime_test.go @@ -182,7 +182,7 @@ func assertNonZeroValues(t *testing.T, sm metricdata.ScopeMetrics) { switch a := m.Data.(type) { case metricdata.Sum[int64]: for _, dp := range a.DataPoints { - assert.True(t, dp.Value > 0, fmt.Sprintf("Metric %q should have a non-zero value for point with attributes %+v", m.Name, dp.Attributes)) + assert.Positive(t, dp.Value, fmt.Sprintf("Metric %q should have a non-zero value for point with attributes %+v", m.Name, dp.Attributes)) } default: t.Fatalf("unexpected data type %v", a) diff --git a/propagators/b3/b3_propagator_test.go b/propagators/b3/b3_propagator_test.go index f111d38247b..a0026e0f413 100644 --- a/propagators/b3/b3_propagator_test.go +++ b/propagators/b3/b3_propagator_test.go @@ -301,7 +301,7 @@ func TestB3EncodingOperations(t *testing.T) { for i, e := range encodings { for j := i + 1; j < i+len(encodings); j++ { o := encodings[j%len(encodings)] - assert.False(t, e == o, "%v == %v", e, o) + assert.NotEqual(t, e, o, "%v == %v", e, o) } }