Skip to content

Commit 6f65881

Browse files
committed
golangci yml configuration cleanup
- re-activate gocritic, disabling rules we do not pass - disable prealloc (considered harmful) - activate golines formatter - comment and re-orgnize linters section Signed-off-by: apostasie <[email protected]>
1 parent 8337102 commit 6f65881

File tree

1 file changed

+59
-54
lines changed

1 file changed

+59
-54
lines changed

.golangci.yml

Lines changed: 59 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,36 @@ issues:
1010
linters:
1111
default: none
1212
enable:
13-
- depguard
13+
# 1. This is the default enabled set of golanci
14+
15+
# We should consider enabling errcheck
16+
# - errcheck
1417
- govet
1518
- ineffassign
16-
- misspell
17-
- nakedret
18-
- prealloc
19-
- revive
2019
- staticcheck
21-
- unconvert
2220
- 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+
2343
settings:
2444
staticcheck:
2545
checks:
@@ -119,7 +139,6 @@ linters:
119139
- name: line-length-limit
120140
# Better dealt with by formatter golines
121141
disabled: true
122-
123142
depguard:
124143
rules:
125144
no-patent:
@@ -141,67 +160,53 @@ linters:
141160
- pkg: github.com/containerd/nerdctl/v2/cmd
142161
desc: pkg must not depend on any cmd files
143162
gocritic:
144-
enabled-checks:
163+
disabled-checks:
164+
# Below are normally enabled by default, but we do not pass
145165
- 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
166+
- ifElseChain
167+
- unslice
168+
- badCall
169+
- assignOp
170+
- commentFormatting
171+
- captLocal
172+
- singleCaseSwitch
173+
- wrapperFunc
174+
- elseif
175+
- regexpMust
176+
enabled-checks:
177+
# Below used to be enabled, but we do not pass anymore
178+
# - paramTypeCombine
179+
# - octalLiteral
180+
# - unnamedResult
181+
# - equalFold
182+
# - sloppyReassign
183+
# - emptyStringTest
184+
# - hugeParam
185+
# - appendCombine
186+
# - stringXbytes
187+
# - ptrToRefParam
188+
# - commentedOutCode
189+
# - rangeValCopy
190+
# - methodExprCall
191+
# - yodaStyleExpr
192+
# - typeUnparen
193+
194+
# We enabled these and we pass
159195
- nilValReturn
160-
- offBy1
161-
- sloppyReassign
162196
- weakCond
163-
- octalLiteral
164-
- appendCombine
165-
- equalFold
166-
- hugeParam
167197
- indexAlloc
168198
- rangeExprCopy
169-
- rangeValCopy
170-
- assignOp
171199
- boolExprSimplify
172-
- captLocal
173-
- commentFormatting
174200
- commentedOutImport
175-
- defaultCaseOrder
176201
- docStub
177-
- elseif
178202
- emptyFallthrough
179-
- emptyStringTest
180203
- hexLiteral
181-
- ifElseChain
182-
- methodExprCall
183-
- regexpMust
184-
- singleCaseSwitch
185-
- sloppyLen
186-
- stringXbytes
187-
- switchTrue
188204
- typeAssertChain
189-
- typeSwitchVar
190-
- underef
191205
- unlabelStmt
192-
- unlambda
193-
- unslice
194-
- valSwap
195-
- wrapperFunc
196-
- yodaStyleExpr
197206
- builtinShadow
198207
- importShadow
199208
- initClause
200209
- nestingReduce
201-
- paramTypeCombine
202-
- ptrToRefParam
203-
- typeUnparen
204-
- unnamedResult
205210
- unnecessaryBlock
206211
exclusions:
207212
generated: disable
@@ -220,14 +225,14 @@ formatters:
220225
gofumpt:
221226
extra-rules: true
222227
golines:
223-
max-len: 100
228+
max-len: 500
224229
tab-len: 4
225230
shorten-comments: true
226231
enable:
227232
- gci
228233
- gofmt
229234
# We might consider enabling the following:
230235
# - gofumpt
231-
# - golines
236+
- golines
232237
exclusions:
233238
generated: disable

0 commit comments

Comments
 (0)