forked from avast/retry-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.golangci.yml
More file actions
240 lines (213 loc) · 7.81 KB
/
.golangci.yml
File metadata and controls
240 lines (213 loc) · 7.81 KB
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
## Golden config for golangci-lint - strict, but within the realm of what Go authors might use.
#
# This is tied to the version of golangci-lint listed in the Makefile, usage with other
# versions of golangci-lint will yield errors and/or false positives.
#
# Docs: https://github.com/golangci/golangci-lint/blob/HEAD/.golangci.reference.yml
# Based heavily on https://gist.github.com/maratori/47a4d00457a92aa426dbd48a18776322
version: "2"
issues:
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
max-issues-per-linter: 0
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
max-same-issues: 0
formatters:
enable:
# - gci
# - gofmt
- gofumpt
# - goimports
# - golines
- swaggo
settings:
golines:
# Default: 100
max-len: 120
linters:
default: all
disable:
# linters that give advice contrary to what the Go authors advise
- decorder # checks declaration order and count of types, constants, variables and functions
- dupword # [useless without config] checks for duplicate words in the source code
- exhaustruct # [highly recommend to enable] checks if all structure fields are initialized
- forcetypeassert # [replaced by errcheck] finds forced type assertions
- ginkgolinter # [if you use ginkgo/gomega] enforces standards of using ginkgo and gomega
- gochecknoglobals # checks that no global variables exist
- cyclop # replaced by revive
- gocyclo # replaced by revive
- forbidigo # needs configuration to be useful
- funlen # replaced by revive
- godox # TODO's are OK
- ireturn # It's OK
- musttag
- nonamedreturns
- goconst # finds repeated strings that could be replaced by a constant
- goheader # checks is file header matches to pattern
- gomodguard # [use more powerful depguard] allow and block lists linter for direct Go module dependencies
- gomoddirectives
- err113 # bad advice about dynamic errors
- lll # [replaced by golines] reports long lines
- mnd # detects magic numbers, duplicated by revive
- nlreturn # [too strict and mostly code is not more readable] checks for a new line before return and branch statements to increase code clarity
- noinlineerr # disallows inline error handling `if err := ...; err != nil {`
- prealloc # [premature optimization, but can be used in some cases] finds slice declarations that could potentially be preallocated
- tagliatelle # needs configuration
- testableexamples # checks if examples are testable (have an expected output)
- testpackage # makes you use a separate _test package
- paralleltest # not every test should be in parallel
- wrapcheck # not required
- wsl # [too strict and mostly code is not more readable] whitespace linter forces you to use empty lines
- wsl_v5 # [too strict and mostly code is not more readable] add or remove empty lines
- zerologlint # detects the wrong usage of zerolog that a user forgets to dispatch zerolog.Event
# All settings can be found here https://github.com/golangci/golangci-lint/blob/HEAD/.golangci.reference.yml
settings:
depguard:
rules:
"deprecated":
files:
- "$all"
deny:
- pkg: github.com/golang/protobuf
desc: Use google.golang.org/protobuf instead, see https://developers.google.com/protocol-buffers/docs/reference/go/faq#modules
- pkg: github.com/satori/go.uuid
desc: Use github.com/google/uuid instead, satori's package is not maintained
- pkg: github.com/gofrs/uuid$
desc: Use github.com/gofrs/uuid/v5 or later, it was not a go module before v5
"non-test files":
files:
- "!$test"
deny:
- pkg: math/rand$
desc: Use math/rand/v2 instead, see https://go.dev/blog/randv2
- pkg: "github.com/sirupsen/logrus"
desc: not allowed
- pkg: "github.com/pkg/errors"
desc: Should be replaced by standard lib errors package
dupl:
# token count (default: 150)
threshold: 300
embeddedstructfieldcheck:
# Checks that sync.Mutex and sync.RWMutex are not used as embedded fields.
forbid-mutex: true
errcheck:
# Report about not checking of errors in type assertions: `a := b.(MyStruct)`.
check-type-assertions: true
check-blank: true
exhaustive:
# Program elements to check for exhaustiveness.
# Default: [ switch ]
check:
- switch
- map
default-signifies-exhaustive: true
fatcontext:
# Check for potential fat contexts in struct pointers.
# May generate false positives.
# Default: false
check-struct-pointers: true
funcorder:
# Checks if the exported methods of a structure are placed before the non-exported ones.
struct-method: false
gocognit:
min-complexity: 55
gocritic:
enable-all: true
disabled-checks:
- paramTypeCombine
# The list of supported checkers can be found at https://go-critic.com/overview.
settings:
captLocal:
# Whether to restrict checker to params only.
paramsOnly: false
underef:
# Whether to skip (*x).method() calls where x is a pointer receiver.
skipRecvDeref: false
hugeParam:
# Default: 80
sizeThreshold: 200
govet:
enable-all: true
godot:
scope: toplevel
inamedparam:
# Skips check for interface methods with only a single parameter.
skip-single-param: true
nakedret:
# Default: 30
max-func-lines: 7
nestif:
min-complexity: 15
nolintlint:
# Exclude following linters from requiring an explanation.
# Default: []
allow-no-explanation: [funlen, gocognit, golines]
# Enable to require an explanation of nonzero length after each nolint directive.
require-explanation: true
# Enable to require nolint directives to mention the specific linter being suppressed.
require-specific: true
revive:
enable-all-rules: true
rules:
- name: add-constant
severity: warning
disabled: true
- name: cognitive-complexity
disabled: true # prefer maintidx
- name: cyclomatic
disabled: true # prefer maintidx
- name: function-length
arguments: [150, 225]
- name: line-length-limit
arguments: [150]
- name: nested-structs
disabled: true
- name: max-public-structs
arguments: [10]
- name: flag-parameter # fixes are difficult
disabled: true
rowserrcheck:
# database/sql is always checked.
# Default: []
packages:
- github.com/jmoiron/sqlx
perfsprint:
# optimize fmt.Sprintf("x: %s", y) into "x: " + y
strconcat: false
staticcheck:
checks:
- all
usetesting:
# Enable/disable `os.TempDir()` detections.
# Default: false
os-temp-dir: true
varnamelen:
max-distance: 75
min-name-length: 2
check-receivers: false
ignore-names:
- r
- w
- f
- err
exclusions:
# Default: []
presets:
- common-false-positives
rules:
# Allow "err" and "ok" vars to shadow existing declarations, otherwise we get too many false positives.
- text: '^shadow: declaration of "(err|ok)" shadows declaration'
linters:
- govet
- text: "parameter 'ctx' seems to be unused, consider removing or renaming it as _"
linters:
- revive
- path: _test\.go
linters:
- dupl
- gosec
- godot
- govet # alignment
- noctx
- perfsprint
- revive
- varnamelen