fix golangci-lint

This commit is contained in:
Luigi Operoso 2024-03-11 22:44:32 +00:00
parent f1b1cbf4ec
commit a8d414f85c
4 changed files with 42 additions and 36 deletions

View File

@ -1,39 +1,37 @@
run: run:
deadline: 10m deadline: 10m
allow-parallel-runners: true
skip-files: skip-files:
- api/v1alpha2/zz_generated.deepcopy.go - api/v1alpha2/zz_generated.deepcopy.go
linters-settings: issues:
errcheck: exclude-use-default: false
check-blank: false exclude-rules:
ignore: fmt:.*,io/ioutil:^Read.*,Write - path: "api/*"
linters: linters:
enable-all: true
disable:
- funlen
- gocognit
- godox
- gomnd
- gochecknoglobals
- gochecknoinits
- lll - lll
- prealloc - path: "internal/*"
- wsl linters:
- gocyclo
- scopelint
- dupl - dupl
- gosec - lll
- maligned linters:
- testpackage disable-all: true
- goerr113 enable:
- dupl
- errcheck
- exportloopref
- goconst
- gocyclo
- gofmt
- goimports
- gosimple
- govet
- ineffassign
- lll
- misspell
- nakedret - nakedret
- nestif - prealloc
- godot - staticcheck
- ifshort - typecheck
- structcheck - unconvert
- deadcode - unparam
- golint - unused
- nosnakecase
- exhaustivestruct
- varcheck
- interfacer

View File

@ -70,10 +70,14 @@ HAS_GOLINT := $(shell which $(PROJECT_DIR)/bin/golangci-lint)
lint: ## Verifies `golint` passes lint: ## Verifies `golint` passes
@echo "+ $@" @echo "+ $@"
ifndef HAS_GOLINT ifndef HAS_GOLINT
GOBIN=$(PROJECT_DIR)/bin go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.52.2 GOBIN=$(PROJECT_DIR)/bin go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.54.2
endif endif
@bin/golangci-lint run @bin/golangci-lint run
.PHONY: lint-fix
lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes
@bin/golangci-lint run --fix
.PHONY: goimports .PHONY: goimports
HAS_GOIMPORTS := $(shell which $(PROJECT_DIR)/bin/goimports) HAS_GOIMPORTS := $(shell which $(PROJECT_DIR)/bin/goimports)
goimports: ## Verifies `goimports` passes goimports: ## Verifies `goimports` passes
@ -371,7 +375,7 @@ kind-clean: ## Delete kind cluster
IMAGE_NAME := quay.io/$(QUAY_ORGANIZATION)/$(QUAY_REGISTRY):$(GITCOMMIT)-amd64 IMAGE_NAME := quay.io/$(QUAY_ORGANIZATION)/$(QUAY_REGISTRY):$(GITCOMMIT)-amd64
BUILD_PRESENT := $(shell docker images |grep -q ${IMAGE_NAME}) BUILD_PRESENT := $(shell docker images |grep -q ${IMAGE_NAME})
ifndef BUILD_PRESENT ifndef BUILD_PRESENT
bats-tests: container-runtime-build-amd64 ## Run bats tests bats-tests: container-runtime-build-amd64 kind-setup ## Run bats tests
@echo "+ $@" @echo "+ $@"
kind load docker-image ${IMAGE_NAME} --name $(KIND_CLUSTER_NAME) kind load docker-image ${IMAGE_NAME} --name $(KIND_CLUSTER_NAME)
OPERATOR_IMAGE="${IMAGE_NAME}" TERM=xterm bats -T -p test/bats OPERATOR_IMAGE="${IMAGE_NAME}" TERM=xterm bats -T -p test/bats

View File

@ -202,7 +202,11 @@ func (jenkins *jenkins) GetNodeSecret(name string) (string, error) {
if err != nil { if err != nil {
return "", errors.WithStack(err) return "", errors.WithStack(err)
} }
defer r.Body.Close() defer func() {
if err := r.Body.Close(); err != nil {
errors.New("Failed to read response body")
}
}()
match := regex.FindStringSubmatch(content) match := regex.FindStringSubmatch(content)
if match == nil { if match == nil {

View File

@ -92,7 +92,7 @@ func (s *testSession) Data(r io.Reader) error {
contentRegex := regexp.MustCompile(`\t+<tr>\n\t+<td><b>(.*):</b></td>\n\t+<td>(.*)</td>\n\t+</tr>`) contentRegex := regexp.MustCompile(`\t+<tr>\n\t+<td><b>(.*):</b></td>\n\t+<td>(.*)</td>\n\t+</tr>`)
headersRegex := regexp.MustCompile(`(.*):\s(.*)`) headersRegex := regexp.MustCompile(`(.*):\s(.*)`)
b, err := ioutil.ReadAll(quotedprintable.NewReader(r)) b, err := io.ReadAll(quotedprintable.NewReader(r))
if err != nil { if err != nil {
return err return err
} }