Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error-nil: add Empty and Zero #138

Closed
ccoVeille opened this issue Jun 20, 2024 · 2 comments
Closed

error-nil: add Empty and Zero #138

ccoVeille opened this issue Jun 20, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@ccoVeille
Copy link
Contributor

we do not detect error used with empty/zero, right now

var err error
assert.Empty(t, err)
assert.Zero(t, err)

We should recommend using NoError

var err error
assert.NoError(t, err)

this pattern is widely used https://github.com/search?q=language%3Ago+%22assert.Empty%28t%2C+err%22&type=code
https://github.com/search?q=language%3Ago+%22assert.Zero%28t%2C+err%29%22&type=code

These two are candidates for error-nil

Originally posted by @ccoVeille in #119 (comment)

@ccoVeille
Copy link
Contributor Author

Please confirm if the logic is valid for you, then I can code it

@Antonboom Antonboom added the enhancement New feature or request label Jun 21, 2024
@Antonboom
Copy link
Owner

Yes, this is valid for me.

Need to add to ignored cases in tests:

assert.Empty(t, errs)
assert.Empty(t, err.String())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants