-
Notifications
You must be signed in to change notification settings - Fork 8
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
Configuration for golangci linter #4
Conversation
could you link a relevant test-infra PR? Other than that, /lgtm |
@mvshao: The following test failed, say
Full PR test history. Your PR dashboard. 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. I understand the commands that are listed here. |
@@ -38,6 +38,14 @@ help: ## Display this help. | |||
|
|||
##@ Development | |||
|
|||
lint-autofix: ## Autofix all possible linting errors. | |||
golangci-lint run -E goimports --fix |
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.
Couldn't we reuse the .golangci.yaml
for fixing? ie instead of -E
, use the file?
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.
In this case, we need to run only one linter, specifically goimports
, which is able to fix errors related to incorrect formatting of imports. Running all the linter does not seem to be optimal in my opinion. This target in the Makefile is supposed to be used, by default, only to fix incorrectly formatted imports.
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.
Couldn't we also fix other lints that do support fixing?
Is this only imports? Probably general formatting could also be done this way, possibly whitespace changes (if we have that lint enabled) etc
Could we do something like "all from config, except non-fast"? IIRC golangci-lint had some tag for fast lints?
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.
For the moment, we just need the goimports fix to be available. Most of the errors that can happen are errors regarding imports. If we see that adding more linters will help solve problems that may arise during further implementation, we will do so in the next iteration. Unfortunately, I could not find in the golangci documentation, a flag that describes a linter as fast.
I'm also not comfortable with the idea of running all linter with the --fix parameter, due to their significant number.
Description
Changes proposed in this pull request:
golangci
linterRelated PR
test-infra