improve lint

This commit is contained in:
Fabiano Graças 2021-11-12 01:07:08 +01:00 committed by Tao Jiang
parent fdbaa68af7
commit 0906af7baf
3 changed files with 23 additions and 11 deletions

View file

@ -40,7 +40,7 @@ jobs:
- name: Lint
shell: bash
run: |
make lint
make lint-docker
- name: Scan
shell: bash

View file

@ -44,9 +44,9 @@ scan: ## - execute static code analysis
lint: ## - runs golangci-lint
@ ./_support/scripts/ci.sh lint
.PHONY: ci-lint-docker
.PHONY: lint-docker
lint-docker: ## - runs golangci-lint with docker container
@ docker run --rm -v "$(shell pwd)":/app -w /app ${LINT_IMAGE} golangci-lint run ${LINT_FLAGS}
@ ./_support/scripts/ci.sh lintDocker
.PHONY: sonar-scan
sonar-scan: ## - start sonar qube locally with docker (you will need docker installed in your machine)

View file

@ -31,14 +31,25 @@ function go_format() {
function lint() {
# golangci-lint run --enable-all -D forbidigo -D gochecknoglobals -D gofumpt -D gofmt -D nlreturn
golangci-lint run \
--skip-files=_mock.go \
--disable=golint \
--skip-dirs=test \
--fast \
--skip-dirs=internal \
--timeout=600s \
--verbose \
"$(local_go_pkgs)"
--verbose
}
function lintDocker() {
lintVersion="1.41.1"
lintImage="golangci/golangci-lint:v$lintVersion-alpine"
docker run --rm -v "${PWD}":/app -w /app "$lintImage" golangci-lint run \
--skip-files=_mock.go \
--skip-dirs=test \
--skip-dirs=internal \
--timeout=600s \
--verbose
}
function test() {
@ -99,6 +110,7 @@ case "$1" in
fmtcheck) checkfmt ;;
format) go_format ;;
lint) lint ;;
lintDocker) lintDocker ;;
unittest) test ;;
scan) scanast ;;
*) usage ;;