Skip to content

Commit

Permalink
Merge pull request #1603 from dexidp/lint
Browse files Browse the repository at this point in the history
Add golangci linter
  • Loading branch information
sagikazarmark authored Dec 18, 2019
2 parents 64b269d + bcd47fc commit e0f927c
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 19 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 45 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -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
28 changes: 16 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ PROJ=dex
ORG_PATH=github.com/dexidp
REPO_PATH=$(ORG_PATH)/$(PROJ)
export PATH := $(PWD)/bin:$(PATH)
THIS_DIRECTORY:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))

VERSION ?= $(shell ./scripts/git-version)

Expand All @@ -18,6 +17,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:
Expand Down Expand Up @@ -45,14 +47,19 @@ test:
testrace:
@go test -v --race ./...

vet:
@go vet ./...
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 $@

fmt:
@./scripts/gofmt ./...
.PHONY: lint
lint: bin/golangci-lint ## Run linter
bin/golangci-lint run

lint: bin/golint
@./bin/golint -set_exit_status $(shell go list ./...)
.PHONY: fix
fix: bin/golangci-lint ## Fix lint violations
bin/golangci-lint run --fix

.PHONY: docker-image
docker-image:
Expand All @@ -73,14 +80,11 @@ bin/protoc: scripts/get-protoc
bin/protoc-gen-go:
@go install -v $(REPO_PATH)/vendor/github.com/golang/protobuf/protoc-gen-go

bin/golint:
@go install -v $(THIS_DIRECTORY)/vendor/golang.org/x/lint/golint

clean:
@rm -rf bin/

testall: testrace vet fmt lint
testall: testrace

FORCE:

.PHONY: test testrace vet fmt lint testall
.PHONY: test testrace testall
7 changes: 0 additions & 7 deletions scripts/gofmt

This file was deleted.

0 comments on commit e0f927c

Please sign in to comment.