-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
🌱 lint: enable revive if-return check and fix findings #7682
Conversation
/test pull-cluster-api-test-main |
.golangci.yml
Outdated
text: "if-return: redundant if ...; err != nil check, just return error instead" | ||
path: .*(api|types|test)\/.*\/conversion.*\.go$ |
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.
nit: can we add a comment explaining why we need these lines?
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.
Do you mean for each specific case? It's in the "Disable linters for conversion" section starting on L266
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.
just a comment for L273 (text) and one for L274 (path) should be enough
the first one is a little bit opaque, why is this necessary?
the second instead seems kind of intuitive (skip the check for ... even if I'm not sure why are we ignoring api|types|test
@@ -289,11 +289,7 @@ func (cm *certManagerClient) migrateCRDs() error { | |||
return err | |||
} | |||
|
|||
if err := newCRDMigrator(c).Run(ctx, objs); err != nil { | |||
return err |
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.
if someone wanted to wrap the error and add more context to it, will the linter complain?
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.
I think that would be fine. I just removed the err assignment since it wasn't needed as the implementation is right now.
05d935f
to
de575ca
Compare
/test pull-cluster-api-test-mink8s-main |
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.
/approve
/lgtm
Good job on also adding comments in golanci-lint!
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: vincepri 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 |
What this PR does / why we need it:
Enables the revive
if-return
check and fixes the findings.Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #7449