-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from henrybear327/feat/add_golangci-lint
Add make verify target for running static analysis checks
- Loading branch information
Showing
12 changed files
with
170 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
GO_CMD="go" | ||
|
||
GOFILES=$(${GO_CMD} list --f "{{with \$d:=.}}{{range .GoFiles}}{{\$d.Dir}}/{{.}}{{\"\n\"}}{{end}}{{end}}" ./...) | ||
TESTGOFILES=$(${GO_CMD} list --f "{{with \$d:=.}}{{range .TestGoFiles}}{{\$d.Dir}}/{{.}}{{\"\n\"}}{{end}}{{end}}" ./...) | ||
XTESTGOFILES=$(${GO_CMD} list --f "{{with \$d:=.}}{{range .XTestGoFiles}}{{\$d.Dir}}/{{.}}{{\"\n\"}}{{end}}{{end}}" ./...) | ||
|
||
echo "${GOFILES}" "${TESTGOFILES}" "${XTESTGOFILES}"| xargs -n 100 go run golang.org/x/tools/cmd/goimports@latest -w -local go.etcd.io | ||
|
||
go fmt ./... | ||
go mod tidy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
--- | ||
run: | ||
timeout: 30m | ||
issues.exclude-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 | ||
- goimports | ||
- ineffassign | ||
- nakedret | ||
- revive | ||
- staticcheck | ||
- stylecheck | ||
- unconvert # Remove unnecessary type conversions | ||
- unparam | ||
- unused | ||
linters-settings: # please keep this alphabetized | ||
goimports: | ||
local-prefixes: go.etcd.io # Put imports beginning with prefix after 3rd-party packages. | ||
nakedret: | ||
# Align with https://github.com/alexkohler/nakedret/blob/v1.0.2/cmd/nakedret/main.go#L10 | ||
max-func-lines: 5 | ||
revive: | ||
ignore-generated-header: false | ||
severity: error | ||
confidence: 0.8 | ||
enable-all-rules: false | ||
rules: | ||
- name: blank-imports | ||
severity: error | ||
disabled: false | ||
- name: context-as-argument | ||
severity: error | ||
disabled: false | ||
- name: dot-imports | ||
severity: error | ||
disabled: false | ||
- name: error-return | ||
severity: error | ||
disabled: false | ||
- name: error-naming | ||
severity: error | ||
disabled: false | ||
- name: if-return | ||
severity: error | ||
disabled: false | ||
- name: increment-decrement | ||
severity: error | ||
disabled: false | ||
- name: var-declaration | ||
severity: error | ||
disabled: false | ||
- name: package-comments | ||
severity: error | ||
disabled: false | ||
- name: range | ||
severity: error | ||
disabled: false | ||
- name: receiver-naming | ||
severity: error | ||
disabled: false | ||
- name: time-naming | ||
severity: error | ||
disabled: false | ||
- name: indent-error-flow | ||
severity: error | ||
disabled: false | ||
- name: errorf | ||
severity: error | ||
disabled: false | ||
- name: context-keys-type | ||
severity: error | ||
disabled: false | ||
- name: error-strings | ||
severity: error | ||
disabled: false | ||
# TODO: enable the following rules | ||
- name: var-naming | ||
disabled: true | ||
- name: exported | ||
disabled: true | ||
- name: unexported-return | ||
disabled: true | ||
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 isn’t allowed | ||
stylecheck: | ||
checks: | ||
- ST1019 # Importing the same package multiple times. |