-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Also, I think |
||
|
||
# Find all the go.mod files in the project. | ||
GO_MOD_FILES := $(filter-out ./go.mod,$(strip $(call R_WILDCARD,./,go.mod))) | ||
GO_MOD_DIRS := $(dir $(GO_MOD_FILES)) | ||
|
||
# CONVERSION_GEN_FALLBACK_MODE determines how to run the conversion-gen tool if | ||
# this project is not in the GOPATH at the expected location. Possible values | ||
# include "symlink" and "docker|podman". | ||
|
@@ -276,10 +283,18 @@ lint: ## Run all the lint targets | |
$(MAKE) lint-shell | ||
|
||
GOLANGCI_LINT_FLAGS ?= --fast=true | ||
GOLANGCI_LINT_ABS_PATH := $(abspath $(GOLANGCI_LINT)) | ||
.PHONY: lint-go | ||
lint-go: $(GOLANGCI_LINT) | ||
lint-go: ## Lint codebase | ||
$(GOLANGCI_LINT) run -v $(GOLANGCI_LINT_FLAGS) | ||
@for dir in $(GO_MOD_DIRS); do \ | ||
if [[ "$$dir" == ./external* || "$$dir" == ./hack/tools* ]]; then \ | ||
echo "Skipping $$dir"; \ | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Are |
||
done | ||
|
||
.PHONY: lint-go-full | ||
lint-go-full: GOLANGCI_LINT_FLAGS = --fast=false | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ package utilconversion | |
import ( | ||
"math/rand" | ||
|
||
//nolint:depguard | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
"github.com/onsi/gomega" | ||
|
||
"github.com/google/go-cmp/cmp" | ||
|
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?