-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add more DQL API feautures, add lint/Makefile (#1)
- Loading branch information
Showing
14 changed files
with
1,033 additions
and
80 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
lint.err | ||
x.json |
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,142 @@ | ||
[run] | ||
timeout = "10m" | ||
issues-exit-code = 1 | ||
skip-files = ["packrd"] | ||
go = "1.18" | ||
skip-dirs = [ | ||
# TODO: we should add lint check on the package | ||
] | ||
|
||
[linters-settings] | ||
|
||
[linters-settings.govet] | ||
check-shadowing = false | ||
|
||
[linters-settings.golint] | ||
min-confidence = 0.0 | ||
|
||
[linters-settings.gocyclo] | ||
min-complexity = 14.0 | ||
|
||
[linters-settings.gocognit] | ||
min-complexity = 14.0 | ||
|
||
[linters-settings.cyclo] | ||
min-complexity = 14.0 | ||
|
||
[linters-settings.maligned] | ||
suggest-new = true | ||
|
||
[linters-settings.goconst] | ||
min-len = 3.0 | ||
min-occurrences = 4.0 | ||
|
||
[linters-settings.misspell] | ||
locale = "US" | ||
|
||
[linters-settings.funlen] | ||
lines = 230 # default 60 | ||
statements = 150 # default 40 | ||
|
||
[linters-settings.forbidigo] | ||
forbid = ['^print(ln)?$', '^spew\.Print(f|ln)?$', '^spew\.Dump$'] | ||
|
||
[linters-settings.depguard] | ||
list-type = "blacklist" | ||
include-go-root = false | ||
packages = ["github.com/pkg/errors"] | ||
|
||
[linters-settings.godox] | ||
keywords = ["FIXME"] | ||
|
||
[linters-settings.wsl] | ||
allow-assign-and-anything = true | ||
|
||
[linters-settings.importas] | ||
corev1 = "k8s.io/api/core/v1" | ||
networkingv1beta1 = "k8s.io/api/networking/v1beta1" | ||
extensionsv1beta1 = "k8s.io/api/extensions/v1beta1" | ||
metav1 = "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
kubeerror = "k8s.io/apimachinery/pkg/api/errors" | ||
|
||
[linters-settings.gomoddirectives] | ||
replace-allow-list = [ | ||
"github.com/abbot/go-http-auth", | ||
"github.com/go-check/check", | ||
"github.com/gorilla/mux", | ||
"github.com/mailgun/minheap", | ||
"github.com/mailgun/multibuf", | ||
] | ||
|
||
[linters-settings.lll] | ||
line-length = 150 | ||
tab-width = 2 | ||
|
||
[linters] | ||
enable-all = true | ||
disable = [ | ||
# 权且放开他们 | ||
"testpackage", # Too strict | ||
"wrapcheck", # 不便于错误处理 | ||
"tagliatelle", # 跟现有 json tag 命名方式 | ||
"paralleltest", # 可开启,改动范围较大 | ||
"noctx", # 要求 HTTP 请求都用 context 形式,改动较大 | ||
"nlreturn", # 要求 return 语句前有一个空行 | ||
"gomnd", # 不放过任何一个魔术数 | ||
"wsl", # 更好代码分段 | ||
"prealloc", # Too many false-positive. | ||
"nestif", # Too many false-positive. | ||
"goerr113", # 不能 fmt.Errorf/errors.New | ||
"gochecknoglobals", # 不能搞全局变量 | ||
"exhaustivestruct", # 结构体初始化字段是否完整 | ||
"golint", # Too strict | ||
"interfacer", | ||
"scopelint", # obsoluted: https://github.com/kyoh86/scopelint#obsoleted | ||
|
||
|
||
# 代码太复杂 | ||
"gocognit", | ||
"gocyclo", | ||
|
||
"dupl", # 还不允许有相似代码 | ||
#"maligned", # deprecated: https://github.com/mdempsky/maligned | ||
|
||
"cyclop", | ||
"gomoddirectives", # used `replace' in go.mod | ||
"nolintlint", | ||
"revive", | ||
"exhaustruct", # [升级 Go1.18 后加入] 要求结构体每次务必每个字段都要填 | ||
"varnamelen", # [升级 Go1.18 后加入] 变量名长度检查 | ||
"nonamedreturns", # [升级 Go1.18 后加入] 不允许函数有名返回 | ||
"forcetypeassert", # [升级 Go1.18 后加入] 强制断言检查 | ||
"gci", # [升级 Go1.18 后加入] Tab 键检查 | ||
"maintidx", # [升级 Go1.18 后加入] 函数长度检查 | ||
"containedctx", # [升级 Go1.18 后加入] Go 不推荐把 context 放在结构体中:https://go.dev/blog/context-and-structs | ||
"ireturn", # [升级 Go1.18 后加入] 函数 interface 返回检查 | ||
"contextcheck", # [升级 Go1.18 后加入] 函数参数必须传入 context | ||
"errchkjson", # [升级 Go1.18 后加入] json 序列化/反序列化必须检查 | ||
"nilnil", # [升级 Go1.18 后加入] 函数返回 nil, nil 检查 | ||
] | ||
|
||
[issues] | ||
exclude-use-default = false | ||
max-per-linter = 0 | ||
max-same-issues = 0 | ||
exclude = [] | ||
|
||
[[issues.exclude-rules]] | ||
path = "(.+)_test.go" | ||
linters = [ | ||
"errcheck", | ||
"goconst", | ||
"funlen", | ||
"godot", | ||
"lll", | ||
"gosec", | ||
"stylecheck", | ||
"wsl", | ||
"unused", | ||
"deadcode", | ||
"unparam", | ||
"maligned", | ||
"varcheck"] |
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,18 @@ | ||
lint: lint_deps | ||
golangci-lint run --fix | tee lint.err # https://golangci-lint.run/usage/install/#local-installation | ||
|
||
lint_deps: gofmt vet | ||
|
||
vet: | ||
@go vet ./... | ||
|
||
gofmt: | ||
@GO111MODULE=off gofmt -l $(shell find . -type f -name '*.go'| grep -v "/vendor/\|/.git/") | ||
|
||
copyright_check: | ||
@python3 copyright.py --dry-run && \ | ||
{ echo "copyright check ok"; exit 0; } || \ | ||
{ echo "copyright check failed"; exit -1; } | ||
|
||
copyright_check_auto_fix: | ||
@python3 copyright.py --fix |
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 was deleted.
Oops, something went wrong.
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
Oops, something went wrong.