Merge pull request #14255 from ramses/golangci-config

Add golangci-lint config file and `make` target.
This commit is contained in:
Benjamin Wang 2022-07-29 15:47:43 +08:00 committed by GitHub
commit 046c46e52e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 52 additions and 1 deletions

37
.golangci.yaml Normal file
View File

@ -0,0 +1,37 @@
run:
go: '1.17'
timeout: 30m
skip-files:
- "^zz_generated.*"
issues:
max-same-issues: 0
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
# exclude ineffassing linter for generated files for conversion
- path: conversion\.go
linters:
- ineffassign
linters:
disable-all: true
enable: # please keep this alphabetized
# Don't use soon to deprecated[1] linters that lead to false
# https://github.com/golangci/golangci-lint/issues/1841
# - deadcode
# - structcheck
# - varcheck
- ineffassign
- staticcheck
- stylecheck
- unused
linters-settings: # please keep this alphabetized
staticcheck:
checks:
- "all"
- "-SA1019" # TODO(fix) Using a deprecated function, variable, constant or field
- "-SA2002" # TODO(fix) Called testing.T.FailNow or SkipNow in a goroutine, which isnt allowed
stylecheck:
checks:
- "ST1019" # Importing the same package multiple times.

View File

@ -92,3 +92,9 @@ commit using message with a more generic `*:` prefix.
*: <what changed>
[..]
```
### Static analysis.
We recommend that you install [golangci-lint](https://golangci-lint.run/usage/install/) and run `make lint`.
Very soon we will have a GitHub action to run our linters.

View File

@ -166,3 +166,11 @@ build-docker-release-main:
push-docker-release-main:
$(info ETCD_VERSION: $(ETCD_VERSION))
docker push gcr.io/etcd-development/etcd:$(ETCD_VERSION)
# Recursively analyzes the tree:
lint:
golangci-lint run
# Fixes found issues, if supported by the linter:
lint-fix:
golangci-lint run --fix

View File

@ -30,7 +30,7 @@ import (
"strconv"
"time"
"go.etcd.io/etcd/client/v3"
clientv3 "go.etcd.io/etcd/client/v3"
"go.etcd.io/etcd/client/v3/concurrency"
)