1+ version : " 2"
2+
3+ formatters :
4+ enable :
5+ - gofumpt
6+ - goimports
7+
8+ settings :
9+ gofumpt :
10+ extra-rules : true
11+
112linters :
2- enable-all : true
13+ default : all
314 disable :
415 - decorder # Don't care about this
516 - dupl # Basically every table driven test ever triggers this
@@ -8,9 +19,9 @@ linters:
819 - exhaustruct # No
920 - forbidigo # Nothing to forbid
1021 - funlen # Bad metric for complexity
11- - gci # gofmt/goimports is fine
1222 - ginkgolinter # I don't use whatever this is
1323 - gochecknoglobals # Globals are fine sometimes, use common sense
24+ - gocognit # Cmplexity with another name, don't need both
1425 - gocyclo # cyclop does this instead
1526 - godox # "todo" and "fixme" comments are allowed
1627 - goheader # No need
@@ -22,125 +33,133 @@ linters:
2233 - nestif # cyclop does this
2334 - nlreturn # Similar to wsl, I think best left to judgement
2435 - nonamedreturns # Named returns are often helpful, it's naked returns that are the issue
25- - paralleltest # No need
26- - tenv # Replaced by usetesting
27- - thelper # Lots of false positives due to the way I do table tests in here
36+ - paralleltest # I've never had Go tests take longer than a few seconds, it's fine
37+ - thelper # Lots of false positives in here due to the way I do table tests
38+ - unparam # gopls is better and more subtle
2839 - varnamelen # Lots of false positives of things that are fine
2940 - wrapcheck # Not every error must be wrapped
3041 - wsl # Very aggressive, some of this I like but tend to do anyway
3142
32- issues :
33- exclude-rules :
34- - path : _test\.go
35- linters :
36- - prealloc # These kinds of optimisations will make no difference to test code
37-
38- linters-settings :
39- cyclop :
40- max-complexity : 20
41-
42- depguard :
43+ exclusions :
44+ presets :
45+ # See https://golangci-lint.run/usage/false-positives/#exclusion-presets
46+ - comments # Revive in particular has lots of false positives
47+ - std-error-handling
48+ - common-false-positives
4349 rules :
44- main :
45- deny :
46- - pkg : io/ioutil
47- desc : io/ioutil is deprecated, use io instead
48-
49- - pkg : " math/rand$"
50- desc : use math/rand/v2 instead
51-
52- errcheck :
53- check-type-assertions : true
54- check-blank : true
55-
56- exhaustive :
57- check :
58- - switch
59- - map
60- default-signifies-exhaustive : true
61-
62- staticcheck :
63- checks :
64- - all
65-
66- gosimple :
67- checks :
68- - all
69-
70- govet :
71- enable-all : true
72-
73- gofumpt :
74- extra-rules : true
75-
76- nakedret :
77- max-func-lines : 0 # Disallow any naked returns
78-
79- nolintlint :
80- allow-unused : false
81- require-explanation : true
82- require-specific : true
83-
84- usetesting :
85- context-background : true
86- context-todo : true
87- os-chdir : true
88- os-mkdir-temp : true
89- os-setenv : true
90- os-create-temp : true
91- os-temp-dir : true
92-
93- revive :
94- max-open-files : 256
95- ignore-generated-header : true
96- enable-all-rules : true
97- rules :
98- - name : add-constant
99- disabled : true # goconst does this
100-
101- - name : argument-limit
102- arguments :
103- - 5
104-
105- - name : cognitive-complexity
106- disabled : true # gocognit does this
107-
108- - name : comment-spacings
109- arguments :
110- - " nolint:"
111-
112- - name : cyclomatic
113- disabled : true # cyclop does this
114-
115- - name : exported
116- arguments :
117- - checkPrivateReceivers
118- - checkPublicInterface
119-
120- - name : function-length
121- disabled : true # Bad proxy for complexity
122-
123- - name : function-result-limit
124- arguments :
125- - 3
126-
127- - name : import-shadowing
128- disabled : true # predeclared does this
129-
130- - name : line-length-limit
131- disabled : true # gofmt/golines handles this well enough
132-
133- - name : redefines-builtin-id
134- disabled : true # predeclared does this
135-
136- - name : unhandled-error
137- arguments :
138- - fmt\.(Fp|P)rint(ln|f)?
139- - strings.Builder.Write(String|Byte)?
140- - bytes.Buffer.Write(String|Byte)?
141-
142- - name : unused-parameter
143- disabled : true # Leaves a mess of _ in test cases etc.
50+ - path : _test\.go
51+ linters :
52+ - prealloc # These kinds of optimisations will make no difference to test code
53+ - gosec # Tests don't need security stuff
54+
55+ settings :
56+ cyclop :
57+ max-complexity : 20
58+
59+ depguard :
60+ rules :
61+ main :
62+ deny :
63+ - pkg : io/ioutil
64+ desc : io/ioutil is deprecated, use io instead
65+
66+ - pkg : " math/rand$"
67+ desc : use math/rand/v2 instead
68+
69+ errcheck :
70+ check-type-assertions : true
71+ check-blank : true
72+
73+ exhaustive :
74+ check :
75+ - switch
76+ - map
77+ default-signifies-exhaustive : true
78+
79+ staticcheck :
80+ checks :
81+ - all
82+
83+ gosec :
84+ excludes :
85+ - G104 # Errors not checked, handled by errcheck
86+
87+ govet :
88+ enable-all : true
89+
90+ nakedret :
91+ max-func-lines : 0 # Disallow any naked returns
92+
93+ nolintlint :
94+ allow-unused : false
95+ require-explanation : true
96+ require-specific : true
97+
98+ usetesting :
99+ context-background : true
100+ context-todo : true
101+ os-chdir : true
102+ os-mkdir-temp : true
103+ os-setenv : true
104+ os-create-temp : true
105+ os-temp-dir : true
106+
107+ revive :
108+ max-open-files : 256
109+ enable-all-rules : true
110+ rules :
111+ - name : add-constant
112+ disabled : true # goconst does this
113+
114+ - name : argument-limit
115+ arguments :
116+ - 5
117+
118+ - name : cognitive-complexity
119+ disabled : true # gocognit does this
120+
121+ - name : comment-spacings
122+ arguments :
123+ - " nolint:"
124+
125+ - name : cyclomatic
126+ disabled : true # cyclop does this
127+
128+ - name : exported
129+ arguments :
130+ - checkPrivateReceivers
131+ - checkPublicInterface
132+
133+ - name : function-length
134+ disabled : true # Bad proxy for complexity
135+
136+ - name : function-result-limit
137+ arguments :
138+ - 3
139+
140+ - name : import-shadowing
141+ disabled : true # predeclared does this
142+
143+ - name : line-length-limit
144+ disabled : true # gofmt/golines handles this well enough
145+
146+ - name : max-public-structs
147+ disabled : true # This is a dumb rule
148+
149+ - name : redefines-builtin-id
150+ disabled : true # predeclared does this
151+
152+ - name : unhandled-error
153+ arguments :
154+ - fmt\.(Fp|P)rint(ln|f)?
155+ - strings.Builder.Write(String|Byte)?
156+ - bytes.Buffer.Write(String|Byte)?
157+
158+ - name : flag-parameter
159+ disabled : true # As far as I can work out this just doesn't like bools
160+
161+ - name : unused-parameter
162+ disabled : true # The gopls unused analyzer covers this better
144163
145- - name : unused-receiver
146- disabled : true # As above
164+ - name : unused-receiver
165+ disabled : true # As above
0 commit comments