@@ -11,64 +11,57 @@ formatters:
1111 extra-rules : true
1212
1313 golines :
14- max-len : 140
14+ max-len : 120
1515
1616linters :
1717 default : all
1818 disable :
19- - decorder # Don't care about this
20- - dupl # Basically every table driven test ever triggers this
21- - dupword # Messes with test cases more often than not
22- - err113 # Out of date
23- - exhaustruct # No
24- - forbidigo # Nothing to forbid
25- - funlen # Bad metric for complexity
26- - ginkgolinter # I don't use whatever this is
27- - gochecknoglobals # Globals are fine sometimes, use common sense
28- - gocyclo # cyclop does this instead
29- - godox # "todo" and "fixme" comments are allowed
30- - goheader # No need
31- - gosmopolitan # No need
32- - grouper # Imports take care of themselves, rest is common sense
33- - ireturn # This is just not necessary or practical in a real codebase
34- - lll # Auto formatters do this and what they can't do I don't care about
35- - maintidx # This is just the inverse of complexity... which is cyclop
36- - nestif # cyclop does this
37- - nlreturn # Similar to wsl, I think best left to judgement
38- - noinlineerr # Inline errors are fine
39- - nonamedreturns # Named returns are often helpful, it's naked returns that are the issue
40- - paralleltest # I've never had Go tests take longer than a few seconds, it's fine
41- - thelper # Everything in here is a helper basically
42- - unparam # gopls is better and more subtle
43- - varnamelen # Lots of false positives of things that are fine
44- - wrapcheck # Not every error must be wrapped
45- - wsl # Very aggressive, some of this I like but tend to do anyway
46- - mnd # Magic numbers are fine, context makes them clear
19+ - cyclop # gocognit is the single complexity linter, cognitive beats cyclomatic
20+ - decorder # Don't care about this
21+ - err113 # Not everything needs this
22+ - exhaustruct # This is just a bad idea
23+ - forbidigo # Nothing to forbid
24+ - funlen # Bad metric for complexity
25+ - goconst # Got significantly more annoying recently
26+ - gocyclo # Prefer cognitive complexity over naive metrics
27+ - godox # "todo" and "fixme" comments are allowed
28+ - gomodguard # Deprecated
29+ - ireturn # AST is full of interfaces we need to return (e.g. Expression)
30+ - lll # Auto formatters do this and what they can't do I don't care about
31+ - maintidx # Prefer cognitive
32+ - mnd # Annoying and too sensitive
33+ - nestif # Nesting depth is the dominant factor in gocognit's score already
34+ - noinlineerr # Inline errors are fine
35+ - nonamedreturns # Named returns are often helpful documentation, it's naked returns that are the issue
36+ - paralleltest # I've never had Go tests take longer than a few seconds, it's fine
37+ - unparam # gopls is better and more subtle
38+ - varnamelen # Lots of false positives of things that are fine
39+ - wrapcheck # Not every error must be wrapped
40+ - wsl # Deprecated
4741
4842 exclusions :
4943 presets :
5044 # See https://golangci-lint.run/usage/false-positives/#exclusion-presets
51- - comments # Revive in particular has lots of false positives
52- - std-error-handling
5345 - common-false-positives
46+ - std-error-handling
5447 rules :
5548 - path : _test\.go
5649 linters :
57- - prealloc # These kinds of optimisations will make no difference to test code
58- - gosec # Tests don't need security stuff
59- - goconst # Nah
60-
61- # test.ErrorAs returns the matched error for optional chained assertions;
62- # discarding it is a supported pattern. errcheck's exclude-functions
63- # doesn't currently match generic instantiations, so match by source instead.
50+ - dupl # Common false positives with table driven tests
51+ - dupword # Messes with test cases more often than not
52+ - gochecknoglobals # Flags and env vars
53+ - goconst # Sometimes repetition is okay in tests
54+ - gosec # Tests don't need security stuff
55+ - prealloc # These kinds of optimisations will make no difference to test code
56+ - thelper # Everything in here could be consider a "helper", this is noisy
57+
58+ # test.ErrorAs returns the matched error for optional chained assertions
59+ # discarding it is a supported pattern
6460 - source : ' test\.ErrorAs\['
6561 linters :
6662 - errcheck
6763
6864 settings :
69- cyclop :
70- max-complexity : 20
71-
7265 depguard :
7366 rules :
7467 main :
@@ -80,100 +73,50 @@ linters:
8073 desc : use math/rand/v2 instead
8174
8275 errcheck :
83- check-type-assertions : true
8476 check-blank : true
77+ check-type-assertions : true
8578
8679 exhaustive :
8780 check :
88- - switch
8981 - map
82+ - switch
9083 default-signifies-exhaustive : true
9184
92- staticcheck :
93- checks :
94- - all
95-
9685 gosec :
9786 excludes :
98- - G104 # Errors not checked, handled by errcheck
87+ - G104 # Errors not checked, handled by errcheck
9988
10089 govet :
10190 enable-all : true
10291
10392 nakedret :
104- max-func-lines : 0 # Disallow any naked returns
93+ max-func-lines : 0 # Disallow any naked returns
10594
10695 nolintlint :
10796 allow-unused : false
10897 require-explanation : true
10998 require-specific : true
11099
100+ revive :
101+ # every other revive rule overlaps one or more of the other
102+ # linters. These are the ones nothing else covers.
103+ enable-all-rules : false
104+ rules :
105+ - name : context-as-argument # ctx must be the first parameter
106+ - name : deep-exit # os.Exit / log.Fatal outside main and init
107+ - name : modifies-parameter # don't mutate value parameters
108+ - name : modifies-value-receiver # value receiver mutations are lost
109+ - name : unexported-return # exported func returning an unexported type
110+
111+ staticcheck :
112+ checks :
113+ - all
114+
111115 usetesting :
112116 context-background : true
113117 context-todo : true
114118 os-chdir : true
119+ os-create-temp : true
115120 os-mkdir-temp : true
116121 os-setenv : true
117- os-create-temp : true
118122 os-temp-dir : true
119-
120- revive :
121- max-open-files : 256
122- enable-all-rules : true
123- rules :
124- - name : add-constant
125- disabled : true # goconst does this
126-
127- - name : argument-limit
128- arguments :
129- - 5
130-
131- - name : cognitive-complexity
132- disabled : true # gocognit does this
133-
134- - name : comment-spacings
135- arguments :
136- - " nolint:"
137-
138- - name : cyclomatic
139- disabled : true # cyclop does this
140-
141- - name : exported
142- arguments :
143- - checkPrivateReceivers
144- - checkPublicInterface
145-
146- - name : function-length
147- disabled : true # Bad proxy for complexity
148-
149- - name : function-result-limit
150- arguments :
151- - 3
152-
153- - name : import-shadowing
154- disabled : true # predeclared does this
155-
156- - name : line-length-limit
157- disabled : true # gofmt/golines handles this well enough
158-
159- - name : max-public-structs
160- disabled : true # This is a dumb rule
161-
162- - name : redefines-builtin-id
163- disabled : true # predeclared does this
164-
165- - name : unhandled-error
166- arguments :
167- - fmt\.(Fp|P)rint(ln|f)?
168- - strings.Builder.Write(String|Byte)?
169- - bytes.Buffer.Write(String|Byte)?
170- - go/printer.(Fp|P)rint(ln|f)?
171-
172- - name : flag-parameter
173- disabled : true # As far as I can work out this just doesn't like bools
174-
175- - name : unused-parameter
176- disabled : true # The gopls unused analyzer covers this better
177-
178- - name : unused-receiver
179- disabled : true # As above
0 commit comments