diff --git a/.ci/check b/.ci/check index 1d1938e3..7f988bf8 100755 --- a/.ci/check +++ b/.ci/check @@ -39,6 +39,8 @@ if [ -z ${GOPATH+x} ]; then fi fi +go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.61.0 + ############################################################################### PACKAGES="$(go list -e ./...)" PACKAGES_DIRS="${PACKAGES//github.com\/gardener\/docforge/.}" @@ -53,6 +55,7 @@ go vet ${PACKAGES} gofmt -l -w ${PACKAGES_DIRS} echo "Executing lint checks" +golangci-lint run for package in ${PACKAGES_DIRS}; do # shellcheck disable=SC2046 $executable -set_exit_status $(find "$package" -maxdepth 1 -name "*.go" | grep -vE '_test.go') diff --git a/.golangci.yaml b/.golangci.yaml new file mode 100644 index 00000000..d9f8c7ae --- /dev/null +++ b/.golangci.yaml @@ -0,0 +1,8 @@ +linters: + enable: + # - gochecknoglobals + - gocyclo + +linters-settings: + gocyclo: + min-complexity: 15 \ No newline at end of file diff --git a/Makefile b/Makefile index 3cdf3916..8f453665 100755 --- a/Makefile +++ b/Makefile @@ -59,7 +59,7 @@ clean: ##################################################################### .PHONY: verify -verify: check test integration-test e2e lint +verify: check test integration-test e2e .PHONY: check check: @@ -103,37 +103,4 @@ generate: .PHONY: task task: - @./task.sh "$(m)" - -.PHONY: lint -lint: golangci-lint ## Run golangci-lint linter & yamllint - $(GOLANGCI_LINT) run - -.PHONY: lint-fix -lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes - $(GOLANGCI_LINT) run --fix - - -##@ Dependencies -## Location to install dependencies to -LOCALBIN ?= $(shell pwd)/bin -$(LOCALBIN): - mkdir -p $(LOCALBIN) - -GOLANGCI_LINT_VERSION ?= v1.61.0 -GOLANGCI_LINT = $(LOCALBIN)/golangci-lint-$(GOLANGCI_LINT_VERSION) - -.PHONY: golangci-lint -golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary. -$(GOLANGCI_LINT): $(LOCALBIN) - $(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,${GOLANGCI_LINT_VERSION}) - -define go-install-tool -@[ -f $(1) ] || { \ -set -e; \ -package=$(2)@$(3) ;\ -echo "Downloading $${package}" ;\ -GOBIN=$(LOCALBIN) go install $${package} ;\ -mv "$$(echo "$(1)" | sed "s/-$(3)$$//")" $(1) ;\ -} -endef \ No newline at end of file + @./task.sh "$(m)" \ No newline at end of file diff --git a/pkg/workers/document/markdown/link_modifier.go b/pkg/workers/document/markdown/link_modifier.go index 895bd8f2..9791c900 100644 --- a/pkg/workers/document/markdown/link_modifier.go +++ b/pkg/workers/document/markdown/link_modifier.go @@ -93,6 +93,7 @@ func (l *linkModifierRenderer) AddOptions(opts ...renderer.Option) { } } +//gocyclo:ignore func (l *linkModifierRenderer) Render(w io.Writer, source []byte, node ast.Node) error { // walk & render nodes r := &Renderer{ diff --git a/pkg/workers/linkvalidator/validator.go b/pkg/workers/linkvalidator/validator.go index b68cce04..a647db79 100644 --- a/pkg/workers/linkvalidator/validator.go +++ b/pkg/workers/linkvalidator/validator.go @@ -45,6 +45,8 @@ func NewValidatorWorker(repository registry.Interface, hostsToReport []string) ( } // Validate validates a link +// +//gocyclo:ignore func (v *ValidatorWorker) Validate(ctx context.Context, LinkDestination string, ContentSourcePath string) error { var ( req *http.Request