@@ -10,16 +10,36 @@ issues:
10
10
linters :
11
11
default : none
12
12
enable :
13
- - depguard
13
+ # 1. This is the default enabled set of golanci
14
+
15
+ # We should consider enabling errcheck
16
+ # - errcheck
14
17
- govet
15
18
- ineffassign
16
- - misspell
17
- - nakedret
18
- - prealloc
19
- - revive
20
19
- staticcheck
21
- - unconvert
22
20
- unused
21
+
22
+ # 2. These are not part of the default set
23
+
24
+ # Important to prevent import of certain packages
25
+ - depguard
26
+ # Removes unnecessary conversions
27
+ - unconvert
28
+ # Flag common typos
29
+ - misspell
30
+ # A meta-linter seen as a good replacement for golint
31
+ - revive
32
+ # Gocritic
33
+ - gocritic
34
+
35
+ # 3. We used to use these, but have now removed them
36
+
37
+ # Use of prealloc is generally premature optimization and performance profiling should be done instead
38
+ # https://golangci-lint.run/usage/linters/#prealloc
39
+ # - prealloc
40
+ # Provided by revive in a better way
41
+ # - nakedret
42
+
23
43
settings :
24
44
staticcheck :
25
45
checks :
@@ -31,93 +51,122 @@ linters:
31
51
- " -ST1020"
32
52
- " -ST1021"
33
53
- " -ST1022"
34
- # FIXME: this below this point is disabled for now, but we should investigate
35
- - " -QF1008" # Omit embedded fields from selector expression https://staticcheck.dev/docs/checks#QF1008
36
- - " -QF1003" # Convert if/else-if chain to tagged switch https://staticcheck.dev/docs/checks#QF1003
37
- - " -QF1009" # Use time.Time.Equal instead of == operator https://staticcheck.dev/docs/checks#QF1009
38
- - " -QF1001" # Apply De Morgan’s law https://staticcheck.dev/docs/checks#QF1001
39
- - " -QF1012" # Use fmt.Fprintf(x, ...) instead of x.Write(fmt.Sprintf(...)) https://staticcheck.dev/docs/checks#QF1012
40
- - " -ST1005" # Expand call to math.Pow https://staticcheck.dev/docs/checks#QF1005
41
- - " -QF1004" # Use strings.ReplaceAll instead of strings.Replace with n == -1 https://staticcheck.dev/docs/checks#QF1004
54
+
55
+ # #### TODO: fix and enable these
56
+ # 4 occurrences.
57
+ # Use fmt.Fprintf(x, ...) instead of x.Write(fmt.Sprintf(...)) https://staticcheck.dev/docs/checks#QF1012
58
+ - " -QF1012"
59
+ # 6 occurrences.
60
+ # Apply De Morgan’s law https://staticcheck.dev/docs/checks#QF1001
61
+ - " -QF1001"
62
+ # 10 occurrences.
63
+ # Convert if/else-if chain to tagged switch https://staticcheck.dev/docs/checks#QF1003
64
+ - " -QF1003"
65
+
66
+ # #### These have been vetted to be disabled.
67
+ # 55 occurrences. Omit embedded fields from selector expression https://staticcheck.dev/docs/checks#QF1008
68
+ # Usefulness is questionable.
69
+ - " -QF1008"
70
+
42
71
revive :
43
72
enable-all-rules : true
44
73
rules :
45
74
# See https://revive.run/r
46
- # Below are unsorted, and we might want to review them to decide which one we want to enable
47
- - name : exported
75
+
76
+ # #### P0: we should do it ASAP.
77
+ - name : max-control-nesting
78
+ # 10 occurences (at default 5). Deep nesting hurts readibility.
79
+ arguments : [7]
80
+ - name : deep-exit
81
+ # 11 occurrences. Do not exit in random places.
48
82
disabled : true
49
- - name : add-constant
83
+ - name : unchecked-type-assertion
84
+ # 14 occurrences. This is generally risky and encourages bad coding for newcomers.
50
85
disabled : true
51
- - name : cognitive-complexity
86
+ - name : bare-return
87
+ # 31 occurrences. Bare returns are just evil, very unfriendly, and make reading and editing much harder.
52
88
disabled : true
53
- - name : package-comments
89
+ - name : import-shadowing
90
+ # 44 occurrences. Shadowing makes things prone to errors / confusing to read.
54
91
disabled : true
55
- - name : cyclomatic
92
+ - name : use-errors-new
93
+ # 84 occurrences. Improves error testing.
56
94
disabled : true
57
- - name : deep-exit
95
+
96
+ # #### P1: consider making a dent on these, but not critical.
97
+ - name : argument-limit
98
+ # 4 occurrences (at default 8). Long windy arguments list for functions are hard to read. Use structs instead.
99
+ arguments : [12]
100
+ - name : unnecessary-stmt
101
+ # 5 occurrences. Increase readability.
58
102
disabled : true
59
- - name : function-length
103
+ - name : defer
104
+ # 7 occurrences. Confusing to read for newbies.
60
105
disabled : true
61
- - name : flag-parameter
106
+ - name : confusing-naming
107
+ # 10 occurrences. Hurts readability.
62
108
disabled : true
63
- - name : max-public-structs
109
+ - name : early-return
110
+ # 10 occurrences. Would improve readability.
64
111
disabled : true
65
- - name : max-control-nesting
112
+ - name : function-result-limit
113
+ # 12 occurrences (at default 3). A function returning many results is probably too big.
114
+ arguments : [7]
115
+ - name : function-length
116
+ # 155 occurrences (at default 0, 75). Really long functions should really be broken up in most cases.
117
+ arguments : [0, 400]
118
+ - name : cyclomatic
119
+ # 204 occurrences (at default 10)
120
+ arguments : [100]
121
+ - name : unhandled-error
122
+ # 222 occurrences. Could indicate failure to handle broken conditions.
66
123
disabled : true
124
+ - name : cognitive-complexity
125
+ arguments : [197]
126
+ # 441 occurrences (at default 7). We should try to lower it (involves significant refactoring).
127
+
128
+ # #### P2: nice to have.
129
+ - name : max-public-structs
130
+ # 7 occurrences (at default 5). Might indicate overcrowding of public API.
131
+ arguments : [21]
67
132
- name : confusing-results
133
+ # 13 occurrences. Have named returns when the type stutters.
134
+ # Makes it a bit easier to figure out function behavior just looking at signature.
68
135
disabled : true
69
- - name : nested-structs
70
- disabled : true
71
- - name : import-alias-naming
72
- disabled : true
73
- - name : filename-format
136
+ - name : comment-spacings
137
+ # 50 occurrences. Makes code look less wonky / ease readability.
74
138
disabled : true
75
139
- name : use-any
76
- disabled : true
77
- # FIXME: we should enable these below
78
- - name : struct-tag
79
- disabled : true
80
- - name : redundant-import-alias
140
+ # 30 occurrences. `any` instead of `interface{}`. Cosmetic.
81
141
disabled : true
82
142
- name : empty-lines
143
+ # 85 occurrences. Makes code look less wonky / ease readability.
83
144
disabled : true
84
- - name : unhandled-error
85
- disabled : true
86
- - name : confusing-naming
87
- disabled : true
88
- - name : unused-parameter
89
- disabled : true
90
- - name : unused-receiver
91
- disabled : true
92
- - name : import-shadowing
93
- disabled : true
94
- - name : use-errors-new
95
- disabled : true
96
- - name : argument-limit
97
- disabled : true
98
- - name : time-equal
99
- disabled : true
100
- - name : defer
101
- disabled : true
102
- - name : early-return
103
- disabled : true
104
- - name : comment-spacings
145
+ - name : package-comments
146
+ # 100 occurrences. Better for documentation...
105
147
disabled : true
106
- - name : function-result-limit
148
+ - name : exported
149
+ # 577 occurrences. Forces documentation of any exported symbol.
107
150
disabled : true
108
- - name : unexported-naming
151
+
152
+ # ##### Permanently disabled. Below have been reviewed and vetted to be unnecessary.
153
+ - name : line-length-limit
154
+ # Formatter `golines` takes care of this.
109
155
disabled : true
110
- - name : unnecessary-stmt
156
+ - name : nested-structs
157
+ # 5 occurrences. Trivial. This is not that hard to read.
111
158
disabled : true
112
- - name : if-return
159
+ - name : flag-parameter
160
+ # 52 occurrences. Not sure if this is valuable.
113
161
disabled : true
114
- - name : unchecked-type-assertion
162
+ - name : unused-parameter
163
+ # 505 occurrences. A lot of work for a marginal improvement.
115
164
disabled : true
116
- - name : bare-return
165
+ - name : unused-receiver
166
+ # 31 occurrences. Ibid.
117
167
disabled : true
118
- # Below have been reviewed and disabled
119
- - name : line-length-limit
120
- # Better dealt with by formatter golines
168
+ - name : add-constant
169
+ # 2605 occurrences. Kind of useful in itself, but unacceptable amount of effort to fix
121
170
disabled : true
122
171
123
172
depguard :
@@ -141,67 +190,53 @@ linters:
141
190
- pkg : github.com/containerd/nerdctl/v2/cmd
142
191
desc : pkg must not depend on any cmd files
143
192
gocritic :
144
- enabled-checks :
193
+ disabled-checks :
194
+ # Below are normally enabled by default, but we do not pass
145
195
- appendAssign
146
- - argOrder
147
- - badCond
148
- - caseOrder
149
- - codegenComment
150
- - commentedOutCode
151
- - deprecatedComment
152
- - dupArg
153
- - dupBranchBody
154
- - dupCase
155
- - dupSubExpr
156
- - exitAfterDefer
157
- - flagDeref
158
- - flagName
196
+ - ifElseChain
197
+ - unslice
198
+ - badCall
199
+ - assignOp
200
+ - commentFormatting
201
+ - captLocal
202
+ - singleCaseSwitch
203
+ - wrapperFunc
204
+ - elseif
205
+ - regexpMust
206
+ enabled-checks :
207
+ # Below used to be enabled, but we do not pass anymore
208
+ # - paramTypeCombine
209
+ # - octalLiteral
210
+ # - unnamedResult
211
+ # - equalFold
212
+ # - sloppyReassign
213
+ # - emptyStringTest
214
+ # - hugeParam
215
+ # - appendCombine
216
+ # - stringXbytes
217
+ # - ptrToRefParam
218
+ # - commentedOutCode
219
+ # - rangeValCopy
220
+ # - methodExprCall
221
+ # - yodaStyleExpr
222
+ # - typeUnparen
223
+
224
+ # We enabled these and we pass
159
225
- nilValReturn
160
- - offBy1
161
- - sloppyReassign
162
226
- weakCond
163
- - octalLiteral
164
- - appendCombine
165
- - equalFold
166
- - hugeParam
167
227
- indexAlloc
168
228
- rangeExprCopy
169
- - rangeValCopy
170
- - assignOp
171
229
- boolExprSimplify
172
- - captLocal
173
- - commentFormatting
174
230
- commentedOutImport
175
- - defaultCaseOrder
176
231
- docStub
177
- - elseif
178
232
- emptyFallthrough
179
- - emptyStringTest
180
233
- hexLiteral
181
- - ifElseChain
182
- - methodExprCall
183
- - regexpMust
184
- - singleCaseSwitch
185
- - sloppyLen
186
- - stringXbytes
187
- - switchTrue
188
234
- typeAssertChain
189
- - typeSwitchVar
190
- - underef
191
235
- unlabelStmt
192
- - unlambda
193
- - unslice
194
- - valSwap
195
- - wrapperFunc
196
- - yodaStyleExpr
197
236
- builtinShadow
198
237
- importShadow
199
238
- initClause
200
239
- nestingReduce
201
- - paramTypeCombine
202
- - ptrToRefParam
203
- - typeUnparen
204
- - unnamedResult
205
240
- unnecessaryBlock
206
241
exclusions :
207
242
generated : disable
@@ -220,14 +255,14 @@ formatters:
220
255
gofumpt :
221
256
extra-rules : true
222
257
golines :
223
- max-len : 100
258
+ max-len : 500
224
259
tab-len : 4
225
260
shorten-comments : true
226
261
enable :
227
262
- gci
228
263
- gofmt
229
264
# We might consider enabling the following:
230
265
# - gofumpt
231
- # - golines
266
+ - golines
232
267
exclusions :
233
268
generated : disable
0 commit comments