Skip to content

Commit

Permalink
[chore]: enable error-nil and nil-compare rules from testifylint (#6133)
Browse files Browse the repository at this point in the history
#### Description

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)
and
[nil-compare](https://github.com/Antonboom/testifylint?tab=readme-ov-file#nil-compare)
rules from [testifylint](https://github.com/Antonboom/testifylint)

Signed-off-by: Matthieu MOREL <[email protected]>
  • Loading branch information
mmorel-35 committed Sep 22, 2024
1 parent ebb34b3 commit 23fd4ad
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 14 deletions.
2 changes: 0 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,9 @@ linters-settings:
disable:
- compares
- error-is-as
- error-nil
- expected-actual
- float-compare
- formatter
- go-require
- negative-positive
- nil-compare
- require-error
2 changes: 1 addition & 1 deletion bridges/prometheus/producer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ func TestProduce(t *testing.T) {
p := NewMetricProducer(WithGatherer(reg))
output, err := p.Produce(context.Background())
if tt.wantErr == nil {
assert.Nil(t, err)
assert.NoError(t, err)
}
require.Equal(t, len(output), len(tt.expected))
for i := range output {
Expand Down
2 changes: 1 addition & 1 deletion detectors/aws/ecs/ecs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func TestDetectCannotReadContainerID(t *testing.T) {
detector := &resourceDetector{utils: detectorUtils}
res, err := detector.Detect(context.Background())

assert.Equal(t, nil, err)
assert.NoError(t, err)
assert.Equal(t, expectedResource, res, "Resource returned is incorrect")
}

Expand Down
8 changes: 4 additions & 4 deletions detectors/aws/ecs/test/ecs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func TestDetectV4LaunchTypeEc2(t *testing.T) {
detector := ecs.NewResourceDetector()
res, err := detector.Detect(context.Background())

assert.Equal(t, nil, err, "Detector should not fail")
assert.NoError(t, err, "Detector should not fail")
assert.Equal(t, expectedResource, res, "Resource returned is incorrect")
}

Expand Down Expand Up @@ -139,7 +139,7 @@ func TestDetectV4LaunchTypeEc2BadContainerArn(t *testing.T) {
detector := ecs.NewResourceDetector()
res, err := detector.Detect(context.Background())

assert.Equal(t, nil, err, "Detector should not fail")
assert.NoError(t, err, "Detector should not fail")
assert.Equal(t, expectedResource, res, "Resource returned is incorrect")
}

Expand Down Expand Up @@ -199,7 +199,7 @@ func TestDetectV4LaunchTypeEc2BadTaskArn(t *testing.T) {
detector := ecs.NewResourceDetector()
res, err := detector.Detect(context.Background())

assert.Equal(t, nil, err, "Detector should not fail")
assert.NoError(t, err, "Detector should not fail")
assert.Equal(t, expectedResource, res, "Resource returned is incorrect")
}

Expand Down Expand Up @@ -259,6 +259,6 @@ func TestDetectV4LaunchTypeFargate(t *testing.T) {
detector := ecs.NewResourceDetector()
res, err := detector.Detect(context.Background())

assert.Equal(t, nil, err, "Detector should not fail")
assert.NoError(t, err, "Detector should not fail")
assert.Equal(t, expectedResource, res, "Resource returned is incorrect")
}
2 changes: 1 addition & 1 deletion detectors/aws/lambda/detector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestDetectSuccess(t *testing.T) {
detector := resourceDetector{}
res, err := detector.Detect(context.Background())

assert.Nil(t, err, "Detector unexpectedly returned error")
assert.NoError(t, err, "Detector unexpectedly returned error")
assert.Equal(t, expectedResource, res, "Resource returned is incorrect")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func TestAppendMiddlewares(t *testing.T) {
if c.expectedError == codes.Unset {
assert.NoError(t, err)
} else {
assert.NotNil(t, err)
assert.Error(t, err)
}

spans := sr.Ended()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func TestDynamodbTags(t *testing.T) {
if cases.expectedError == codes.Unset {
assert.NoError(t, err)
} else {
assert.NotNil(t, err)
assert.Error(t, err)
}

spans := sr.Ended()
Expand Down Expand Up @@ -163,7 +163,7 @@ func TestDynamodbTagsCustomSetter(t *testing.T) {
if cases.expectedError == codes.Unset {
assert.NoError(t, err)
} else {
assert.NotNil(t, err)
assert.Error(t, err)
}

spans := sr.Ended()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ func TestStreamClientInterceptorOnUnidirectionalClientServerStream(t *testing.T)
// and RecvMsg() calls.
_ = streamClient.CloseSend()
err := streamClient.RecvMsg(reply)
require.Nil(t, err)
require.NoError(t, err)

// wait for span end that is called in separate go routine
var span trace.ReadOnlySpan
Expand Down
2 changes: 1 addition & 1 deletion samplers/aws/xray/internal/manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func TestMatchAgainstManifestRulesAttributeWildCardMatch(t *testing.T) {
require.NoError(t, err)

// assert that manifest rule r1 is a match
assert.Nil(t, err)
assert.NoError(t, err)
assert.Equal(t, *exp, r1)
}

Expand Down

0 comments on commit 23fd4ad

Please sign in to comment.