From 7e14008ed8c7c408053b442dc40ba64313628d82 Mon Sep 17 00:00:00 2001 From: Todd Gruben Date: Wed, 27 Oct 2021 13:35:42 -0500 Subject: [PATCH] add golangci-lint to gitlab container --- .gitlab/.gitlab-ci.yml | 20 +++++++++++++++++++- .golangci.yml | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/.gitlab/.gitlab-ci.yml b/.gitlab/.gitlab-ci.yml index 0e41bfd1e..20329e6e0 100644 --- a/.gitlab/.gitlab-ci.yml +++ b/.gitlab/.gitlab-ci.yml @@ -64,6 +64,24 @@ generate coverage html: needs: - job: run go tests +install goci: + stage: build + image: golang:1.16.9 + script: + - echo "Installing golangci-lint" + - GO111MODULE=off go get github.com/golangci/golangci-lint/cmd/golangci-lint + artifacts: + paths: + - /go/bin/golangci-lint + +run goci: + stage: test + image: golang:1.16.9 + script: + - echo "Running golangci-lint" + needs: + - job: install goci + upload to sonarcloud: stage: test image: sonarsource/sonar-scanner-cli:4.6 @@ -121,4 +139,4 @@ build for darwin arm64: - go build -o featurebase_darwin_arm64 ./cmd/featurebase artifacts: paths: - - featurebase_darwin_arm64 \ No newline at end of file + - featurebase_darwin_arm64 diff --git a/.golangci.yml b/.golangci.yml index 3c51570cc..1b186c89e 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,3 +1,39 @@ run: + #skip the protobuf generated files + skip-dirs: + - pb + - proto skip-files: - pql/pql.peg.go +linters-settings: + gofmt: + simplify: true + govet: + # report about shadowed variables + check-shadowing: true + + # settings per analyzer + settings: + printf: # analyzer name, run `go tool vet help` to see all analyzers + funcs: # run `go tool vet help printf` to see available settings for `printf` analyzer + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf + + # enable or disable analyzers by name + # run `go tool vet help` to see all analyzers + enable: + - atomicalign + enable-all: false + disable: + - shadow + disable-all: false + + staticcheck: + # Select the Go version to target. The default is '1.13'. + go: "1.16" + # https://staticcheck.io/docs/options#checks + checks: [ "all" ] + +