Skip to content

Commit

Permalink
Move linter config to .golangci.yml and remove surplus Makefile lines (
Browse files Browse the repository at this point in the history
  • Loading branch information
webvictim authored Mar 19, 2021
1 parent 029acc9 commit 854d5fc
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 19 deletions.
34 changes: 34 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
issues:
exclude-rules:
- linters: gosimple
text: "S1002: should omit comparison to bool constant"
exclude-use-default: true
max-same-issues: 0
max-issues-per-linter: 0

linters:
disable-all: true
enable:
- bodyclose
- deadcode
- goimports
- golint
- gosimple
- govet
- ineffassign
- misspell
- staticcheck
- structcheck
- typecheck
- unused
- unconvert
- varcheck

output:
uniq-by-line: false

run:
skip-dirs:
- vendor
skip-dirs-use-default: false
timeout: 5m
16 changes: 2 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ CGOFLAG = CGO_ENABLED=1 CC=aarch64-linux-gnu-gcc
endif
endif

GO_LINTERS ?= "unused,govet,typecheck,deadcode,goimports,varcheck,structcheck,bodyclose,staticcheck,ineffassign,unconvert,misspell,gosimple,golint"

OS ?= $(shell go env GOOS)
ARCH ?= $(shell go env GOARCH)
FIPS ?=
Expand Down Expand Up @@ -293,7 +291,7 @@ integration-root:

#
# Lint the Go code.
# By default lint scans the entire repo. Pass FLAGS='--new' to only scan local
# By default lint scans the entire repo. Pass GO_LINT_FLAGS='--new' to only scan local
# changes (or last commit).
#
.PHONY: lint
Expand All @@ -302,17 +300,7 @@ lint: lint-sh lint-helm lint-go
.PHONY: lint-go
lint-go: GO_LINT_FLAGS ?=
lint-go:
golangci-lint run \
--disable-all \
--exclude-use-default \
--exclude='S1002: should omit comparison to bool constant' \
--skip-dirs vendor \
--uniq-by-line=false \
--max-same-issues=0 \
--max-issues-per-linter 0 \
--timeout=5m \
--enable $(GO_LINTERS) \
$(GO_LINT_FLAGS)
golangci-lint run -c .golangci.yml $(GO_LINT_FLAGS)

# TODO(awly): remove the `--exclude` flag after cleaning up existing scripts
.PHONY: lint-sh
Expand Down
4 changes: 2 additions & 2 deletions build.assets/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ ENV GOPATH="/go" \
PATH="$PATH:/opt/go/bin:/go/bin:/go/src/github.com/gravitational/teleport/build"

# Install meta-linter.
RUN (curl -L https://github.com/golangci/golangci-lint/releases/download/v1.24.0/golangci-lint-1.24.0-$(go env GOOS)-$(go env GOARCH).tar.gz | tar -xz && \
cp golangci-lint-1.24.0-$(go env GOOS)-$(go env GOARCH)/golangci-lint /bin/ && \
RUN (curl -L https://github.com/golangci/golangci-lint/releases/download/v1.38.0/golangci-lint-1.38.0-$(go env GOOS)-$(go env GOARCH).tar.gz | tar -xz && \
cp golangci-lint-1.38.0-$(go env GOOS)-$(go env GOARCH)/golangci-lint /bin/ && \
rm -r golangci-lint*)

# Install helm.
Expand Down
5 changes: 2 additions & 3 deletions lib/auth/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,8 @@ func (t *TLSServer) Shutdown(ctx context.Context) error {
func (t *TLSServer) Serve() error {
errC := make(chan error, 2)
go func() {
if err := t.mux.Serve(); err != nil {
t.log.WithError(err).Warningf("Mux serve failed.")
}
err := t.mux.Serve()
t.log.WithError(err).Warningf("Mux serve failed.")
}()
go func() {
errC <- t.httpServer.Serve(t.mux.HTTP())
Expand Down

0 comments on commit 854d5fc

Please sign in to comment.