-
Notifications
You must be signed in to change notification settings - Fork 49
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
🌱 Add sub-modules in go lint and fix reported issues #897
base: main
Are you sure you want to change the base?
Conversation
First of all, thank you for this. I really appreciate you taking the effort and doing this without anyone asking. Second, unfortunately, I already went down this route and did not open this exact PR because of the same things you did to avoid the issues:
Ultimately we need a special linter config for the |
My suggestion is to refactor this PR to include the fixes to the linter errors, such as ending comments with a |
30484b2
to
7623fab
Compare
7623fab
to
4da7686
Compare
4da7686
to
be48a60
Compare
Minimum allowed line rate is |
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 didn't really review the actual lint fixes that carefully as I am guessing you are simply fixing the warnings. Rest looks good modulo a few questions.
@@ -48,6 +48,13 @@ PROJECT_SLUG := github.com/vmware-tanzu/vm-operator | |||
# ROOT_DIR_IN_GOPATH is non-empty if ROOT_DIR is in the GOPATH. | |||
ROOT_DIR_IN_GOPATH := $(findstring $(GOPATH)/src/$(PROJECT_SLUG),$(ROOT_DIR)) | |||
|
|||
# R_WILDCARD recursively searches for a file that matches $1. |
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.
Matches $2 in $1 no?
@@ -48,6 +48,13 @@ PROJECT_SLUG := github.com/vmware-tanzu/vm-operator | |||
# ROOT_DIR_IN_GOPATH is non-empty if ROOT_DIR is in the GOPATH. | |||
ROOT_DIR_IN_GOPATH := $(findstring $(GOPATH)/src/$(PROJECT_SLUG),$(ROOT_DIR)) | |||
|
|||
# R_WILDCARD recursively searches for a file that matches $1. | |||
R_WILDCARD=$(wildcard $(1)$(2)) $(foreach DIR,$(wildcard $(1)*),$(call R_WILDCARD,$(DIR)/,$(2))) |
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.
Also, I think $(foreach DIR,$(wildcard $(1)*)
also lists files in $1, so you should change it to $(foreach DIR,$(wildcard $(1)*/)
?
continue; \ | ||
fi; \ | ||
echo "Running golangci-lint in $$dir"; \ | ||
(cd $$dir && $(GOLANGCI_LINT_ABS_PATH) run -v $(GOLANGCI_LINT_FLAGS)); \ |
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.
Are GO_MOD_DIRS
relative paths? If so I am curious how cd $$dir
is working here since you pasted the output of running this target in your Testing Done
section.
@@ -16,6 +16,7 @@ package utilconversion | |||
import ( | |||
"math/rand" | |||
|
|||
//nolint:depguard |
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 am curious why we are hitting this. Is this now included in the allowed imports? Or this is because of deprecation etc?
What does this PR do, and why is it needed?
Currently
golangci-lint
doesn't support multiple modules as reported in golangci/golangci-lint#828, so ourapi/
and other submodules are never being linted.This PR addresses this by updating the
lint-go
Makefile target to run thegolangci-lint
command in each module.The
.golangci.yml
is updated to ignore some of the rules specific to_conversion.go
files by using thepath:
param.Which issue(s) is/are addressed by this PR?
Fixes N/A.
Are there any special notes for your reviewer:
make lint-go-full
command locally and passed:make fix
didn't fix issues that were explicitly excluded.Please add a release note if necessary:
📚 Documentation preview 📚: https://vm-operator--897.org.readthedocs.build/en/897/