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 - name: Lint
shell: bash shell: bash
run: | run: |
make lint make lint-docker
- name: Scan - name: Scan
shell: bash shell: bash

View file

@ -44,9 +44,9 @@ scan: ## - execute static code analysis
lint: ## - runs golangci-lint lint: ## - runs golangci-lint
@ ./_support/scripts/ci.sh lint @ ./_support/scripts/ci.sh lint
.PHONY: ci-lint-docker .PHONY: lint-docker
lint-docker: ## - runs golangci-lint with docker container 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 .PHONY: sonar-scan
sonar-scan: ## - start sonar qube locally with docker (you will need docker installed in your machine) 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() { function lint() {
# golangci-lint run --enable-all -D forbidigo -D gochecknoglobals -D gofumpt -D gofmt -D nlreturn # golangci-lint run --enable-all -D forbidigo -D gochecknoglobals -D gofumpt -D gofmt -D nlreturn
golangci-lint run \
--skip-files=_mock.go \ golangci-lint run \
--disable=golint \ --skip-files=_mock.go \
--skip-dirs=test \ --skip-dirs=test \
--fast \ --skip-dirs=internal \
--timeout=600s \ --timeout=600s \
--verbose \ --verbose
"$(local_go_pkgs)" }
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() { function test() {
@ -99,6 +110,7 @@ case "$1" in
fmtcheck) checkfmt ;; fmtcheck) checkfmt ;;
format) go_format ;; format) go_format ;;
lint) lint ;; lint) lint ;;
lintDocker) lintDocker ;;
unittest) test ;; unittest) test ;;
scan) scanast ;; scan) scanast ;;
*) usage ;; *) usage ;;