Browse Source

Add golangci linter

pull/1603/head
Mark Sagi-Kazar 6 years ago
parent
commit
9346e328ef
No known key found for this signature in database
GPG Key ID: 34CC109EB5ED1C2A
  1. 3
      .github/workflows/ci.yml
  2. 45
      .golangci.yml
  3. 23
      Makefile

3
.github/workflows/ci.yml

@ -71,6 +71,9 @@ jobs:
- name: Run Kubernetes tests
run: ./scripts/test-k8s.sh
- name: Run linter
run: make lint
# Ensure proto generation doesn't depend on external packages.
- name: Verify proto
run: make verify-proto

45
.golangci.yml

@ -0,0 +1,45 @@
run:
skip-dirs:
- vendor
linters-settings:
golint:
min-confidence: 0.1
goimports:
local-prefixes: github.com/dexidp/dex
linters:
enable-all: true
disable:
- funlen
- maligned
- wsl
# TODO: fix me
- unused
- structcheck
- stylecheck
- deadcode
- misspell
- unparam
- goimports
- golint
- whitespace
- goconst
- unconvert
- bodyclose
- staticcheck
- nakedret
- ineffassign
- errcheck
- gosec
- gochecknoinits
- gochecknoglobals
- prealloc
- scopelint
- lll
- dupl
- gocritic
- gocyclo
- gocognit
- godox

23
Makefile

@ -18,6 +18,9 @@ export GOBIN=$(PWD)/bin
LD_FLAGS="-w -X $(REPO_PATH)/version.Version=$(VERSION)"
# Dependency versions
GOLANGCI_VERSION = 1.21.0
build: bin/dex bin/example-app bin/grpc-client
bin/dex:
@ -45,13 +48,27 @@ test:
testrace:
@go test -v --race ./...
bin/golangci-lint: bin/golangci-lint-${GOLANGCI_VERSION}
@ln -sf golangci-lint-${GOLANGCI_VERSION} bin/golangci-lint
bin/golangci-lint-${GOLANGCI_VERSION}:
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | BINARY=golangci-lint bash -s -- v${GOLANGCI_VERSION}
@mv bin/golangci-lint $@
.PHONY: lint
lint: bin/golangci-lint ## Run linter
bin/golangci-lint run
.PHONY: fix
fix: bin/golangci-lint ## Fix lint violations
bin/golangci-lint run --fix
vet:
@go vet ./...
fmt:
@./scripts/gofmt ./...
lint: bin/golint
oldlint: bin/golint
@./bin/golint -set_exit_status $(shell go list ./...)
.PHONY: docker-image
@ -79,8 +96,8 @@ bin/golint:
clean:
@rm -rf bin/
testall: testrace vet fmt lint
testall: testrace vet fmt oldlint
FORCE:
.PHONY: test testrace vet fmt lint testall
.PHONY: test testrace vet fmt oldlint testall

Loading…
Cancel
Save