-
Notifications
You must be signed in to change notification settings - Fork 0
/
.golangci.toml
142 lines (118 loc) · 3.76 KB
/
.golangci.toml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
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"]