diff options
author | Alessio Caiazza <acaiazza@gitlab.com> | 2019-09-04 10:46:31 +0300 |
---|---|---|
committer | Alessio Caiazza <acaiazza@gitlab.com> | 2019-09-04 11:00:14 +0300 |
commit | 3ee9d6f8dd9331c599449991504f97bb075eb4a0 (patch) | |
tree | 3fcb1225ee3c82a6943be159728fb75b66c4d8b5 | |
parent | e52008397276437ce28bef3686df7562e281cf9d (diff) |
Enable code-qualityac-gocyclo
-rw-r--r-- | .codeclimate.yml | 24 | ||||
-rw-r--r-- | .gitlab-ci.yml | 14 | ||||
-rw-r--r-- | Makefile.util.mk | 5 | ||||
-rwxr-xr-x | scripts/codequality | 21 |
4 files changed, 63 insertions, 1 deletions
diff --git a/.codeclimate.yml b/.codeclimate.yml new file mode 100644 index 00000000..77c30df4 --- /dev/null +++ b/.codeclimate.yml @@ -0,0 +1,24 @@ +--- +version: "2" +plugins: + structure: + enabled: false + duplication: + enabled: false + gofmt: + enabled: true + golint: + enabled: true + govet: + enabled: true + gocyclo: + enabled: true + config: + over: 9 + fixme: + enabled: false + shellcheck: + enabled: false +exclude_patterns: +- vendor/ +- .GOPATH/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 32819b76..b4d61a04 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,6 +17,20 @@ license_management: variables: SETUP_CMD: echo "Skip setup. Dependency already vendored" +code_quality: + image: docker:19.03-git + services: + - docker:19.03-dind + variables: + DOCKER_DRIVER: overlay2 + CODECLIMATE_FORMAT: json + dependencies: [] + script: + - ./scripts/codequality analyze -f json --dev | tee gl-code-quality-report.json + artifacts: + paths: [gl-code-quality-report.json] + expire_in: 7d + verify: image: golang:1.11 script: diff --git a/Makefile.util.mk b/Makefile.util.mk index 626d146b..44a94b6a 100644 --- a/Makefile.util.mk +++ b/Makefile.util.mk @@ -1,7 +1,10 @@ -.PHONY: verify fmt vet lint complexity test cover list +.PHONY: verify fmt vet lint complexity test cover list codequality verify: list fmt vet lint complexity +codequality: + ./scripts/codequality analyze --dev + fmt: bin/goimports .GOPATH/.ok $Q @./bin/goimports -local $(IMPORT_PATH) -l $(allfiles) | awk '{ print } END { if (NR>0) { print "Please run ./bin/goimports -w -local $(IMPORT_PATH) -l $(allfiles)"; exit 1 } }' diff --git a/scripts/codequality b/scripts/codequality new file mode 100755 index 00000000..820281d4 --- /dev/null +++ b/scripts/codequality @@ -0,0 +1,21 @@ +#!/bin/sh + +set -eo pipefail + +code_path=$(pwd) + +# docker run --tty will merge stderr and stdout, we don't need this on CI or +# it will break codequality json file +[ "$CI" != "" ] || docker_tty="--tty" + +# Preparing gocyclo analyzer +docker pull registry.gitlab.com/nolith/codeclimate-gocyclo > /dev/null +docker tag registry.gitlab.com/nolith/codeclimate-gocyclo codeclimate/codeclimate-gocyclo > /dev/null + +# Executing codeclimate check +exec docker run --rm $docker_tty --env CODECLIMATE_CODE="$code_path" \ + --volume "$code_path":/code \ + --volume /var/run/docker.sock:/var/run/docker.sock \ + --volume /tmp/cc:/tmp/cc \ + codeclimate/codeclimate:0.85.5 "$@" + |