-
Notifications
You must be signed in to change notification settings - Fork 87
/
.golangci.yml
148 lines (133 loc) · 3.75 KB
/
.golangci.yml
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
143
144
145
146
147
148
linters-settings:
gosec:
config:
# Maximum allowed permissions mode file creation
# Default: "0600"
G306: "0644"
excludes:
- G115 # Annoying and have a lot of false-positive results.
gocyclo:
min-complexity: 15
maligned:
suggest-new: true
dupl:
threshold: 120
goconst:
min-len: 2
min-occurrences: 3
misspell:
locale: US
lll:
line-length: 140
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
disabled-checks:
- emptyStringTest # len(<string>) > 0 is fine and easier to read in some contexts
- hugeParam
- rangeValCopy
- exitAfterDefer
- octalLiteral
- httpNoBody
- unnecessaryBlock # for UUID encoder
linters:
enable:
- dogsled
- errcheck
- goconst
- gocritic
- revive
- gosec
- govet
- ineffassign
- lll
- misspell
- nakedret
- typecheck
- unconvert
- unparam
- whitespace
- unused
# Do not enable:
# - wsl (too opinionated about newlines)
# - godox (todos are OK)
# - bodyclose (false positives on helper functions)
# - prealloc (not worth it in scope of this project)
# - maligned (same as prealloc)
# - funlen (gocyclo is enough)
# - gochecknoglobals (we know when it is ok to use globals)
# - gochecknoinits (we know when it is ok to use inits)
# - dupl (validator/parser package are false positive)
issues:
exclude-use-default: false
exclude-rules:
# Exclude go:generate from lll
- source: "//go:generate"
linters: [lll]
# Exclude links from lll
- source: "// See https://"
linters: [lll]
# Disable linters that are annoying in tests.
- path: _test\.go
linters:
- gocyclo
- errcheck
- dupl
- gosec
- funlen
- goconst
- gocognit
- scopelint
- lll
# Do not warn about unused closure parameters in test files.
- path: _test\.go
linters: [unparam]
text: .*\$\d?
# Ignore shadowing of err.
- linters: [govet]
text: 'declaration of "(err|ctx|log)"'
# Ignore linters in main packages.
- path: (cmd|tools)
linters: [goconst, funlen, gocognit, gocyclo]
# TODO(tdakkota): add comments?
- path: (conv|uri|gen|otelogen)
linters: [revive, golint]
text: "(should have comment.+or be unexported|comment on exported)"
# We don't need package comments for internal packages.
# We don't need comments for command packages.
- path: (cmd|tools|internal)
linters: [revive, golint]
text: "should have (comment.+or be unexported|a package comment)"
# Annoying and useless.
- linters: [revive, golint]
text: "(unused-parameter|if-return)"
- linters: [gocritic]
text: ptrToRefParam
source: handleSchemaDepth
# Intended in commands:
# G307: Deferring unsafe method "Close" on type "*os.File"
# G304: Potential file inclusion via variable
- path: (cmd|tools)
text: G(304|306|307)
# Nobody cares.
# G114: Use of net/http serve function that has no support for setting timeouts
- path: techempower
text: G114
# We are using quoting algorithm from mime/multipart package. False-positive.
- path: (http|uri)
source: form-data; name="%s"
linters: [gocritic]
text: sprintfQuotedString
# Keep empty fallthrough for better readability.
- path: ogenregex[/\\]convert\.go
linters: [gocritic]
text: emptyFallthrough
# Not supposed to be constant.
- linters: [goconst]
text: 'string `(string|number|u?int\d{0,2}|float\d{2})`'
- linters: [goconst]
text: "string `(Unix|unix|date|time|ipv6)"