-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
🌱 (chore): Enable wrapcheck linter #4721
base: master
Are you sure you want to change the base?
🌱 (chore): Enable wrapcheck linter #4721
Conversation
Hi @kersten. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @kersten
Thanks a lot for this PR — enabling linters like depguard
and wrapcheck
is a great step toward improving overall code quality and consistency 🙌
That said, regarding depguard
specifically for github.com/pkg/errors
:
This package is currently brought in indirectly by several upstream dependencies, including controller-runtime
, client-go
, and other Kubernetes-related libraries, as shown by:
go mod graph | grep github.com/pkg/errors
sigs.k8s.io/kubebuilder/testdata/project-v4 github.com/pkg/[email protected]
github.com/cert-manager/[email protected] github.com/pkg/[email protected]
gomodules.xyz/jsonpatch/[email protected] github.com/pkg/[email protected]
k8s.io/[email protected] github.com/pkg/[email protected]
k8s.io/[email protected] github.com/pkg/[email protected]
k8s.io/[email protected] github.com/pkg/[email protected]
k8s.io/[email protected] github.com/pkg/[email protected]
k8s.io/[email protected] github.com/pkg/[email protected]
sigs.k8s.io/[email protected] github.com/pkg/[email protected]
sigs.k8s.io/[email protected] github.com/pkg/[email protected]
Because of that, adding depguard
with a deny rule for github.com/pkg/errors
might not be very effective right now — it could lead to confusion or unnecessary friction, especially since we're not using it directly in our own codebase.
It might make more sense to enforce this rule only once those upstream dependencies have fully transitioned to the standard errors
package, if that’s indeed their intended direction. (If you believe that’s the case, I’d recommend opening issues in the relevant upstream projects that are still using it.)
The addition of wrapcheck
, however, shows make sense.
Thanks again for driving quality improvements like this! 💚
@camilamacedo86 Sounds good, I’ll remove the deny rule. If we decide to go with When they see linter messages like “please wrap the error,” they might end up googling and using something like |
4ab98fc
to
6111cf9
Compare
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: camilamacedo86, kersten The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Hi @kersten 👋 If we enable these linters, we'll need to update the codebase to ensure everything passes — see the failing job here: Also, it's worth noting that many of the failures appear to be false positives, or at least cases where the current code seems intentional and correct. While linters are great tools for maintaining consistency and catching real issues, we also need to weigh their practical impact. So before moving forward, I think it’s worth asking: Thanks again for looking into ways to improve the project! 🙏 |
6111cf9
to
94574d6
Compare
Fair enough, I firstly removed depguard anyways because of much noise. But as I understood, |
0f21003
to
c527b03
Compare
Hi @kersten
That is fine. |
c527b03
to
cd0a1ab
Compare
cd0a1ab
to
83be525
Compare
🌱 Enable
wrapcheck
linterThis change improves code quality by enforcing two new linting rule:
wrapcheck
ensures wrapped errors are properly handled and not silently ignored.The motivation is to promote modern Go practices and ensure consistent error wrapping and checking across the codebase.