@@ -11,57 +11,51 @@ formatters:
1111 extra-rules : true
1212
1313 golines :
14- max-len : 140
15- shorten-comments : true
16- reformat-tags : true
14+ max-len : 120
1715
1816linters :
1917 default : all
2018 disable :
21- - cyclop # I prefer cognitive complexity
22- - decorder # Don't care about this
23- - dupl # Basically every table driven test ever triggers this
24- - dupword # Messes with test cases more often than not
25- - err113 # Opaque errors are fine
26- - exhaustruct # No
27- - forbidigo # Nothing to forbid
28- - funlen # Bad metric for complexity
29- - gocyclo # I prefer cognitive complexity
30- - godox # "todo" and "fixme" comments are allowed
31- - goheader # No need
32- - gomodguard # Deprecated in v2.12.0, replaced by gomodguard_v2 which is enabled by default
33- - gosmopolitan # No need
34- - grouper # Imports take care of themselves, rest is common sense
35- - ireturn # Returning an interface is sometimes a good abstraction
36- - lll # Auto formatters do this and what they can't do I don't care about
37- - nlreturn # Similar to wsl
38- - noinlineerr # Inline errors are fine
39- - nonamedreturns # Used sparingly in short functions these are fine
40- - paralleltest # This makes go test -v ./... much more difficult to read
41- - thelper # Lots of false positives in here due to the way I do table tests
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 # Deprecated
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+ - gocyclo # Prefer cognitive complexity over naive metrics
26+ - godox # "todo" and "fixme" comments are allowed
27+ - gomodguard # Deprecated
28+ - ireturn # The Arg and Flag interfaces are intentionally opaque
29+ - lll # Auto formatters do this and what they can't do I don't care about
30+ - maintidx # Prefer cognitive
31+ - mnd # Annoying and too sensitive
32+ - nestif # Nesting depth is the dominant factor in gocognit's score already
33+ - noinlineerr # Inline errors are fine
34+ - nonamedreturns # Named returns are often helpful documentation, it's naked returns that are the issue
35+ - paralleltest # I've never had Go tests take longer than a few seconds, it's fine
36+ - unparam # gopls is better and more subtle
37+ - varnamelen # Lots of false positives of things that are fine
38+ - wrapcheck # Not every error must be wrapped
39+ - wsl # Deprecated
4640
4741 exclusions :
4842 presets :
4943 # See https://golangci-lint.run/usage/false-positives/#exclusion-presets
50- - std-error-handling
5144 - common-false-positives
45+ - std-error-handling
5246 rules :
5347 - path : _test\.go
5448 linters :
55- - prealloc # These kinds of optimisations will make no difference to test code
56- - gosec # Tests don't need security stuff
57- - gochecknoglobals # e.g. global test flags
58- - goconst # Table driven tests naturally repeat string literals
59- - maintidx # Flags table driven tests
49+ - dupl # Common false positives with table driven tests
50+ - dupword # Messes with test cases more often than not
51+ - gochecknoglobals # Flags and env vars
52+ - goconst # Sometimes repetition is okay in tests
53+ - gosec # Tests don't need security stuff
54+ - gosmopolitan # Testing unicode flags etc.
55+ - thelper # Lots of false positives because of how I've done CLI tests
56+ - prealloc # These kinds of optimisations will make no difference to test code
6057
6158 settings :
62- cyclop :
63- max-complexity : 20
64-
6559 depguard :
6660 rules :
6761 main :
@@ -73,105 +67,50 @@ linters:
7367 desc : use math/rand/v2 instead
7468
7569 errcheck :
76- check-type-assertions : true
7770 check-blank : true
71+ check-type-assertions : true
7872
7973 exhaustive :
8074 check :
81- - switch
8275 - map
76+ - switch
8377 default-signifies-exhaustive : true
8478
85- staticcheck :
86- checks :
87- - all
88-
8979 gosec :
9080 excludes :
91- - G104 # Errors not checked, handled by errcheck
81+ - G104 # Errors not checked, handled by errcheck
9282
9383 govet :
9484 enable-all : true
9585
9686 nakedret :
97- max-func-lines : 0 # Disallow any naked returns
87+ max-func-lines : 0 # Disallow any naked returns
9888
9989 nolintlint :
10090 allow-unused : false
10191 require-explanation : true
10292 require-specific : true
10393
94+ revive :
95+ # every other revive rule overlaps one or more of the other
96+ # linters. These are the ones nothing else covers.
97+ enable-all-rules : false
98+ rules :
99+ - name : context-as-argument # ctx must be the first parameter
100+ - name : deep-exit # os.Exit / log.Fatal outside main and init
101+ - name : modifies-parameter # don't mutate value parameters
102+ - name : modifies-value-receiver # value receiver mutations are lost
103+ - name : unexported-return # exported func returning an unexported type
104+
105+ staticcheck :
106+ checks :
107+ - all
108+
104109 usetesting :
105110 context-background : true
106111 context-todo : true
107112 os-chdir : true
113+ os-create-temp : true
108114 os-mkdir-temp : true
109115 os-setenv : true
110- os-create-temp : true
111116 os-temp-dir : true
112-
113- revive :
114- max-open-files : 256
115- enable-all-rules : true
116- rules :
117- - name : add-constant
118- disabled : true # goconst does this
119-
120- - name : argument-limit
121- arguments :
122- - 5
123-
124- - name : cognitive-complexity
125- disabled : true # gocognit does this
126-
127- - name : comment-spacings
128- arguments :
129- - " nolint:"
130-
131- - name : cyclomatic
132- disabled : true # cyclop does this
133-
134- - name : enforce-switch-style
135- disabled : true # exhaustive handles this
136-
137- - name : exported
138- arguments :
139- - checkPrivateReceivers
140- - checkPublicInterface
141-
142- - name : function-length
143- disabled : true # Bad proxy for complexity
144-
145- - name : function-result-limit
146- arguments :
147- - 3
148-
149- - name : import-shadowing
150- disabled : true # predeclared does this
151-
152- - name : line-length-limit
153- disabled : true # gofmt/golines handles this well enough
154-
155- - name : max-public-structs
156- disabled : true # This is a dumb rule
157-
158- - name : redefines-builtin-id
159- disabled : true # predeclared does this
160-
161- - name : unhandled-error
162- disabled : true # errcheck handles this
163-
164- - name : flag-parameter
165- disabled : true # As far as I can work out this just doesn't like bools
166-
167- - name : unused-parameter
168- disabled : true # The gopls unused analyzer covers this better
169-
170- - name : unused-receiver
171- disabled : true # As above
172-
173- - name : var-naming
174- disabled : true
175-
176- - name : package-naming
177- disabled : true
0 commit comments