1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2024-12-26 21:05:00 +02:00

[chore]: enable error-nil rule from testifylint (#5843)

Testifylint is a linter that provides best practices with the use of
testify.

This PR enables
[error-nil](https://github.com/Antonboom/testifylint?tab=readme-ov-file#error-nil)
rule from [testifylint](https://github.com/Antonboom/testifylint)

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Co-authored-by: Robert Pająk <pellared@hotmail.com>
This commit is contained in:
Matthieu MOREL 2024-09-25 11:07:59 +02:00 committed by GitHub
parent 316114c0b8
commit d284a86fa5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 8 additions and 14 deletions

View File

@ -306,7 +306,6 @@ linters-settings:
testifylint:
enable-all: true
disable:
- error-nil
- expected-actual
- float-compare
- go-require

View File

@ -131,7 +131,7 @@ func TestMetricProducer(t *testing.T) {
if tc.expectErr {
require.Error(t, err)
} else {
require.Nil(t, err)
require.NoError(t, err)
}
require.Equal(t, len(output), len(tc.expected))
for i := range output {

View File

@ -15,7 +15,6 @@ import (
func requireErrorString(t *testing.T, expect string, err error) {
t.Helper()
require.NotNil(t, err)
require.Error(t, err)
require.ErrorIs(t, err, PartialSuccess{})

View File

@ -35,7 +35,7 @@ func TestMultiErr(t *testing.T) {
me := &multiErr{datatype: name}
t.Run("ErrOrNil", func(t *testing.T) {
require.Nil(t, me.errOrNil())
require.NoError(t, me.errOrNil())
me.errs = []error{e0}
assert.Error(t, me.errOrNil())
})

View File

@ -15,7 +15,6 @@ import (
func requireErrorString(t *testing.T, expect string, err error) {
t.Helper()
require.NotNil(t, err)
require.Error(t, err)
require.ErrorIs(t, err, PartialSuccess{})

View File

@ -35,7 +35,7 @@ func TestMultiErr(t *testing.T) {
me := &multiErr{datatype: name}
t.Run("ErrOrNil", func(t *testing.T) {
require.Nil(t, me.errOrNil())
require.NoError(t, me.errOrNil())
me.errs = []error{e0}
assert.Error(t, me.errOrNil())
})

View File

@ -15,7 +15,6 @@ import (
func requireErrorString(t *testing.T, expect string, err error) {
t.Helper()
require.NotNil(t, err)
require.Error(t, err)
require.ErrorIs(t, err, PartialSuccess{})

View File

@ -15,7 +15,6 @@ import (
func requireErrorString(t *testing.T, expect string, err error) {
t.Helper()
require.NotNil(t, err)
require.Error(t, err)
require.ErrorIs(t, err, PartialSuccess{})

View File

@ -88,7 +88,7 @@ func TestExporterExportSpan(t *testing.T) {
// write to buffer for testing
var b bytes.Buffer
ex, err := stdouttrace.New(append(tt.opts, stdouttrace.WithWriter(&b))...)
require.Nil(t, err)
require.NoError(t, err)
err = ex.ExportSpans(tt.ctx, tracetest.SpanStubs{ss, ss}.Snapshots())
assert.Equal(t, tt.wantErr, err)

View File

@ -35,7 +35,7 @@ func TestMultiErr(t *testing.T) {
me := &multiErr{datatype: name}
t.Run("ErrOrNil", func(t *testing.T) {
require.Nil(t, me.errOrNil())
require.NoError(t, me.errOrNil())
me.errs = []error{e0}
assert.Error(t, me.errOrNil())
})

View File

@ -15,7 +15,6 @@ import (
func requireErrorString(t *testing.T, expect string, err error) {
t.Helper()
require.NotNil(t, err)
require.Error(t, err)
require.ErrorIs(t, err, PartialSuccess{})

View File

@ -55,8 +55,8 @@ func TestConfigReaderSignalsEmpty(t *testing.T) {
require.NotNil(t, s)
ctx := context.Background()
assert.Nil(t, f(ctx))
assert.Nil(t, s(ctx))
assert.NoError(t, f(ctx))
assert.NoError(t, s(ctx))
assert.ErrorIs(t, s(ctx), ErrReaderShutdown)
}

View File

@ -370,7 +370,7 @@ func testStoredError(t *testing.T, target interface{}) {
err := handler.errs[0]
require.Implements(t, (*error)(nil), target)
require.NotNil(t, target.(error))
require.Error(t, target.(error))
defer handler.Reset()
if errors.Is(err, target.(error)) {