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

View File

@ -70,10 +70,14 @@ HAS_GOLINT := $(shell which $(PROJECT_DIR)/bin/golangci-lint)
lint: ## Verifies `golint` passes
@echo "+ $@"
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
@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
HAS_GOIMPORTS := $(shell which $(PROJECT_DIR)/bin/goimports)
goimports: ## Verifies `goimports` passes
@ -371,7 +375,7 @@ kind-clean: ## Delete kind cluster
IMAGE_NAME := quay.io/$(QUAY_ORGANIZATION)/$(QUAY_REGISTRY):$(GITCOMMIT)-amd64
BUILD_PRESENT := $(shell docker images |grep -q ${IMAGE_NAME})
ifndef BUILD_PRESENT
bats-tests: container-runtime-build-amd64 ## Run bats tests
bats-tests: container-runtime-build-amd64 kind-setup ## Run bats tests
@echo "+ $@"
kind load docker-image ${IMAGE_NAME} --name $(KIND_CLUSTER_NAME)
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 {
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)
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>`)
headersRegex := regexp.MustCompile(`(.*):\s(.*)`)
b, err := ioutil.ReadAll(quotedprintable.NewReader(r))
b, err := io.ReadAll(quotedprintable.NewReader(r))
if err != nil {
return err
}