-
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
Investigate if we should enable additional linters (through golangci-lint) #4622
Comments
@enxebre @fabriziopandini @vincepri If this sounds reasonable to you, I would take a look if I can find some useful (and non-contentious) linters. |
Here's a list of golangci-lint based linters I've used on other projects. For the most part I think they wouldn't be too contentious, though there may be a couple (certain gocritic cases) where we may want to tweak some of the specific linter settings. linters:
disable-all: true
enable:
- bodyclose
- deadcode
- depguard
- dogsled
- dupl
- errcheck
- funlen
- goconst
- gocritic
- gocyclo
- gofmt
- goheader
- goimports
- golint
- gomnd
- goprintffuncname
- gosec
- gosimple
- govet
- ineffassign
- maligned
- misspell
- nakedret
- noctx
- nolintlint
- rowserrcheck
- staticcheck
- structcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- varcheck
- whitespace Happy to help in this effort too, if you need it. |
@stmcginnis You can just take it over if you want :). Depending on how much open linter findings we have to fix then we should/could probably create a list and flag the issue with help wanted? (once we have a list with non-contentious ones) |
Sounds good @sbueringer! I'll do some local checking and see how badly that list complains, then share that here. /assign |
To get the discussion started I've submitted #4624 That has a list of other checks we can enable that others can comment on if they feel they are contentious or not. Biggest impact from the ones not included in that change are two related to docstrings: whether packages have godocs (maybe contentious) and whether doc string matches function names (which triggered this discussion in the first place, so hopefully not contentious). |
@stmcginnis @fabriziopandini @vincepri I adjusted the issue description above to reflect the open tasks. I would suggest adding the help wanted label, wdyt? |
Sounds good. Working on the next step now, but would be good to capture more that we want to do under this issue and see if we want to crowdsource knocking those out. |
@stmcginnis Ah, alright. Let's just try to make clear which parts are already in progress and which might be available for crowdsourcing (in case there are any - your choice). Let me know if I should adjust the issue description in any way. |
Another suggestion. There's also an If we want to use it, I would restrict it to certain very frequently imported packages. Here is an example config: linters-settings:
importas:
apierrors: k8s.io/apimachinery/pkg/api/errors
appsv1: k8s.io/api/apps/v1
authorizationv1: k8s.io/api/authorization/v1
batchv1: k8s.io/api/batch/v1
corev1: k8s.io/api/core/v1
metav1: k8s.io/apimachinery/pkg/apis/meta/v1
rbacv1: k8s.io/api/rbac/v1 I think this would be probably the list I would use, plus a few CAPI specific packages. |
Short update. Looks like we're making good progress, very nice! After #4804 we only have to fix the remaining excludes and we're done:
|
/milestone v0.4 |
/help |
@vincepri: Please ensure the request meets the requirements listed here. If this request no longer meets these requirements, the label can be removed In response to this:
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/test-infra repository. |
Regarding:
I would prefer the first option. |
As per #4928 (comment) it seems that we are not linting comments on the APIs |
@fabriziopandini Looks like revive does not enforce comments on exported fields (but on types and funcs): https://github.com/mgechev/revive/blob/master/rule/exported.go I think the linter is compliant to CodeReviewComments:
In this case it wasn't a top-level name as it's a field. I also couldn't find another linter (supported by golangci-lint) which does this. So short of writing a linter ourselves I don't see a good solution here (and that's probably (?) not worth it). |
@fabriziopandini In case you want to follow-up on the comment linting, I think we should create a new issue for that. (just because the by far most part of the current issue has been implemented and I don't see a straightforward way to implement comment-linting on fields) |
User Story
As a reviewer I would like to focus on reviewing the most relevant changes in PRs and not too much on nitpicking.
Detailed Description
The amount of cleanup PRs we get (although they are great!) suggests that we have a few gaps in our linting.
I think we should investigate if there are some additional linters we could easily enable via golangci-lint (https://golangci-lint.run/usage/linters/).
Anything else you would like to add:
As matters of code style can be very contentious I would suggest the following process:
xref: #4607 (comment)
Tasks:
/kind feature
The text was updated successfully, but these errors were encountered: