-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path.golangci.yaml
180 lines (179 loc) · 4.98 KB
/
.golangci.yaml
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
# We may as well allow multiple golangci-lint invocations at once.
run:
allow-parallel-runners: true
# golangci-lint by default ignores some staticcheck and vet raised issues that
# are actually important to catch. The following ensures that we do not ignore
# those tools ever.
issues:
exclude-rules:
- path: (.+)_test.go
linters:
- bodyclose
- stylecheck
- goconst
- gosec
exclude-use-default: false
max-same-issues: 0 # 0 is unlimited
linters:
disable-all: true
enable:
# Enabled by default linters: we want all except errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- unused
# Not enabled by default: we want a good chunk
- asasalint
- asciicheck
- bidichk
- bodyclose
- containedctx
- cyclop
- durationcheck
- errname
- errorlint
- exhaustive
- gci
- gocheckcompilerdirectives
- gocognit
- goconst
- gocritic
- gocyclo
- gofmt
- gofumpt
- goimports
- goprintffuncname
- gosec
- misspell
- nakedret
- nilerr
- noctx
- nolintlint
- reassign
- revive
- rowserrcheck
- sqlclosecheck
- stylecheck
- tenv
- typecheck
- unconvert
- unparam
- usestdlibvars
- wastedassign
- whitespace
linters-settings:
# A default case ensures we have checked everything. We should not require
# every enum to be checked if we want to default.
exhaustive:
default-signifies-exhaustive: true
# If we want to opt out of a lint, we require an explanation.
nolintlint:
allow-unused: false
require-explanation: true
require-specific: true
# We do not want every usage of fmt.Errorf to use %w.
errorlint:
errorf: false
# If gofumpt is run outside of a module, it assumes Go 1.0 rather than the
# latest Go. We always want the latest formatting.
#
# https://github.com/mvdan/gofumpt/issues/137
gosec:
excludes:
- G104 # unhandled errors, we exclude for the same reason we do not use errcheck
# Complexity analysis: the recommendations are to be between 10-20, with a
# default of 30 for gocyclo and gocognit, and a default of 10 for cyclop. We
# will choose the middle of the range for cyclo analysis, which should be
# good enough for a lot of cases. We can bump to 20 later if necessary. The
# cognitive analysis is a bit overly sensitive for large switch statements
# (say a function just switches to return a bunch of different strings), so
# we will keep its larger default of 30.
#
# cyclop provides no extra benefit to gocyclo because we are not using
# package average, but that's a weird metric nothing else adds.
cyclop:
max-complexity: 16
gocyclo:
min-complexity: 30
gocognit:
min-complexity: 30
gci:
sections:
- standard # stdlib
- default # everything not std, not within project
- prefix(github.com/redpanda-data/common-go)
# Gocritic is a meta linter that has very good lints, and most of the
# experimental ones are very good too. There are only a few we want to opt
# out of specifically.
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
disabled-checks:
- evalOrder
- importShadow
# disabled due to 1.18 failures
- hugeParam
- rangeValCopy
- typeDefFirst
- paramTypeCombine
- unnamedResult
#settings:
# hugeParam:
# sizeThreshold: 256
# rangeValCopy:
# sizeThreshold: 256
# Revive is yet another metalinter with a bunch of useful lints. The below
# opts in to all of the ones we would like to use.
revive:
ignore-generated-header: true
enable-all-rules: true
severity: warning
confidence: 0.7
rules:
# removed because replacing the version of a proto is easier if we use it
# as alias
- name: redundant-import-alias
disabled: true
- name: add-constant
disabled: true
- name: argument-limit
disabled: true
- name: banned-characters
disabled: true
- name: cognitive-complexity
disabled: true
- name: confusing-naming
disabled: true
- name: cyclomatic
disabled: true
- name: file-header
disabled: true
- name: flag-parameter
disabled: true
- name: function-result-limit
disabled: true
- name: function-length
disabled: true
- name: import-shadowing
disabled: true
- name: line-length-limit
disabled: true
- name: max-public-structs
disabled: true
- name: modifies-parameter
disabled: true
- name: nested-structs
disabled: true
- name: package-comments # https://github.com/mgechev/revive/issues/740; stylecheck's ST1000 is better
disabled: true
- name: redefines-builtin-id
disabled: true
- name: unhandled-error
disabled: true
- name: var-naming
disabled: true