mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-28 13:15:33 +01:00
add lint with golangci-lint, remove golint (#16821)
Signed-off-by: yminer <yminer@vmmware.com> test ut_install.sh Signed-off-by: yminer <yminer@vmmware.com> test ut_install.sh001 Signed-off-by: yminer <yminer@vmmware.com> test ut_install002 Signed-off-by: yminer <yminer@vmmware.com> use curl binary to download golangcilint instead of go get Signed-off-by: yminer <yminer@vmmware.com> test ut-ci make lint Signed-off-by: yminer <yminer@vmmware.com> check ci GO111MODULE Signed-off-by: yminer <yminer@vmmware.com> test ci go env Signed-off-by: yminer <yminer@vmmware.com> test ci goenv 002 Signed-off-by: yminer <yminer@vmmware.com> test ci GO111MODULE=auto Signed-off-by: yminer <yminer@vmmware.com> ci test entire ut_install.sh Signed-off-by: yminer <yminer@vmmware.com> remove needless debug comment Signed-off-by: yminer <yminer@vmmware.com> Co-authored-by: yminer <yminer@vmmware.com>
This commit is contained in:
parent
c333218ba2
commit
1f797fafc4
24
Makefile
24
Makefile
@ -516,16 +516,7 @@ gosec:
|
||||
$(GOPATH)/bin/gosec -fmt=json -out=harbor_gas_output.json -quiet ./... | true ; \
|
||||
fi
|
||||
|
||||
go_check: gen_apis mocks_check misspell gofmt commentfmt golint govet
|
||||
|
||||
gofmt:
|
||||
@echo checking gofmt...
|
||||
@res=$$(gofmt -d -e -s $$(find . -type d \( -path ./src/vendor -o -path ./tests \) -prune -o -name '*.go' -print)); \
|
||||
if [ -n "$${res}" ]; then \
|
||||
echo checking gofmt fail... ; \
|
||||
echo "$${res}"; \
|
||||
exit 1; \
|
||||
fi
|
||||
go_check: gen_apis mocks_check misspell commentfmt lint
|
||||
|
||||
commentfmt:
|
||||
@echo checking comment format...
|
||||
@ -541,13 +532,12 @@ misspell:
|
||||
@echo checking misspell...
|
||||
@find . -type d \( -path ./src/vendor -o -path ./tests \) -prune -o -name '*.go' -print | xargs misspell -error
|
||||
|
||||
golint:
|
||||
@echo checking golint...
|
||||
@go list ./... | grep -v -E 'vendor|test' | xargs fgt golint
|
||||
|
||||
govet:
|
||||
@echo checking govet...
|
||||
@cd src;go list ./... | grep -v -E 'vendor|test' | xargs go vet
|
||||
# go get -u github.com/golangci/golangci-lint/cmd/golangci-lint@v1.45.2
|
||||
GOLANGCI_LINT := $(shell go env GOPATH)/bin/golangci-lint
|
||||
lint:
|
||||
@echo checking lint
|
||||
@echo $(GOLANGCI_LINT)
|
||||
@$(GOLANGCI_LINT) -v run ./src/...
|
||||
|
||||
pushimage:
|
||||
@echo "pushing harbor images ..."
|
||||
|
56
src/.golangci.yaml
Normal file
56
src/.golangci.yaml
Normal file
@ -0,0 +1,56 @@
|
||||
linters-settings:
|
||||
gofmt:
|
||||
# Simplify code: gofmt with `-s` option.
|
||||
# Default: true
|
||||
simplify: false
|
||||
misspell:
|
||||
locale: US,UK
|
||||
|
||||
linters:
|
||||
disable-all: true
|
||||
enable:
|
||||
- gofmt
|
||||
- goheader
|
||||
- misspell
|
||||
# - typecheck
|
||||
# - dogsled
|
||||
# - dupl
|
||||
# - depguard
|
||||
# - funlen
|
||||
# - goconst
|
||||
# - gocritic
|
||||
# - gocyclo
|
||||
# - goimports
|
||||
# - goprintffuncname
|
||||
# - ineffassign
|
||||
# - nakedret
|
||||
# - nolintlint
|
||||
# - revive
|
||||
# - whitespace
|
||||
# - bodyclose
|
||||
# - deadcode
|
||||
# - errcheck
|
||||
# - gosec
|
||||
# - gosimple
|
||||
# - govet
|
||||
# - noctx
|
||||
# - rowserrcheck
|
||||
# - staticcheck
|
||||
# - structcheck
|
||||
# - stylecheck
|
||||
# - unconvert
|
||||
# - unparam
|
||||
# - unused
|
||||
# - varcheck
|
||||
|
||||
run:
|
||||
skip-files:
|
||||
- ".*_test.go"
|
||||
- ".*test.go"
|
||||
skip-dir:
|
||||
- "./testing/"
|
||||
timeout: 5m
|
||||
|
||||
issue:
|
||||
max-same-issues: 0
|
||||
max-per-linter: 0
|
@ -13,10 +13,14 @@ go get github.com/stretchr/testify
|
||||
go get golang.org/x/tools/cmd/cover
|
||||
go get github.com/mattn/goveralls
|
||||
go get -u github.com/client9/misspell/cmd/misspell
|
||||
# binary will be $(go env GOPATH)/bin/golangci-lint
|
||||
# go install/go get installation aren't guaranteed to work. We recommend using binary installation.
|
||||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.45.2
|
||||
sudo service postgresql stop || echo no postgresql need to be stopped
|
||||
sleep 2
|
||||
|
||||
sudo rm -rf /data/*
|
||||
sudo go env -w GO111MODULE=auto
|
||||
sudo -E env "PATH=$PATH" make go_check
|
||||
sudo ./tests/hostcfg.sh
|
||||
sudo ./tests/generateCerts.sh
|
||||
|
Loading…
Reference in New Issue
Block a user