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

ci: add errorlint #9

Merged
merged 1 commit into from
Jul 31, 2024
Merged

ci: add errorlint #9

merged 1 commit into from
Jul 31, 2024

Conversation

kolyshkin
Copy link
Owner

This is based on and currently includes #8. Draft until #8 is merged.

With the added linter, it complains like this:

capability_linux.go:349:22: type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors (errorlint)

In fact, errors from syscall.Syscall6 used by prctl are bare Errno
values. This means there is no need for a type assertion, so let's
remove it:

- if errno, ok := err.(syscall.Errno); ok && errno == syscall.EINVAL {
+ if err == syscall.EINVAL {

With that change, we're still getting error from the linter, a bit
different one:

capability_linux.go:349:9: comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)

So, we still need to silence it, by adding a nolint annotation.

With the added linter, it complains like this:

> capability_linux.go:349:22: type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors (errorlint)

In fact, errors from syscall.Syscall6 used by prctl are bare Errno
values. This means there is no need for a type assertion, so let's
remove it:

	> - if errno, ok := err.(syscall.Errno); ok && errno == syscall.EINVAL {
	> + if err == syscall.EINVAL {

With that change, we're still getting error from the linter, a bit
different one:

> capability_linux.go:349:9: comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)

So, we still need to silence it, by adding a nolint annotation.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@kolyshkin kolyshkin marked this pull request as ready for review July 31, 2024 18:05
@kolyshkin kolyshkin merged commit 271809a into main Jul 31, 2024
5 checks passed
@kolyshkin kolyshkin deleted the errorlint branch July 31, 2024 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant