1+ # See https://golangci-lint.run/usage/configuration/
2+ # Over time we should try tightening some of these.
3+
4+ linters-settings :
5+ dupl :
6+ # goal: 100
7+ threshold : 412
8+
9+ exhaustruct :
10+ include :
11+ # Gradually extend to cover more of the codebase.
12+ - ' httpmw\.\w+'
13+ # We want to enforce all values are specified when inserting or updating
14+ # a database row. Ref: #9936
15+ - ' github.com/coder/coder/v2/coderd/database\.[^G][^e][^t]\w+Params'
16+ gocognit :
17+ min-complexity : 300
18+
19+ goconst :
20+ min-len : 4 # Min length of string consts (def 3).
21+ min-occurrences : 3 # Min number of const occurrences (def 3).
22+
23+ gocritic :
24+ enabled-checks :
25+ # - appendAssign
26+ # - appendCombine
27+ # - assignOp
28+ # - badCall
29+ - badLock
30+ - badRegexp
31+ - boolExprSimplify
32+ # - builtinShadow
33+ - builtinShadowDecl
34+ # - commentedOutCode
35+ - commentedOutImport
36+ - deferUnlambda
37+ # - deprecatedComment
38+ # - docStub
39+ - dupImport
40+ # - elseif
41+ - emptyFallthrough
42+ # - emptyStringTest
43+ # - equalFold
44+ # - evalOrder
45+ # - exitAfterDefer
46+ # - exposedSyncMutex
47+ # - filepathJoin
48+ - hexLiteral
49+ # - httpNoBody
50+ # - hugeParam
51+ # - ifElseChain
52+ # - importShadow
53+ - indexAlloc
54+ - initClause
55+ - methodExprCall
56+ # - nestingReduce
57+ - nilValReturn
58+ # - octalLiteral
59+ # - paramTypeCombine
60+ # - preferStringWriter
61+ # - preferWriteByte
62+ # - ptrToRefParam
63+ # - rangeExprCopy
64+ # - rangeValCopy
65+ - regexpPattern
66+ # - regexpSimplify
67+ - ruleguard
68+ # - sloppyReassign
69+ - sortSlice
70+ - sprintfQuotedString
71+ - sqlQuery
72+ # - stringConcatSimplify
73+ # - stringXbytes
74+ # - suspiciousSorting
75+ - truncateCmp
76+ - typeAssertChain
77+ # - typeDefFirst
78+ # - typeUnparen
79+ # - unlabelStmt
80+ # - unlambda
81+ # - unnamedResult
82+ # - unnecessaryBlock
83+ # - unnecessaryDefer
84+ # - unslice
85+ - weakCond
86+ # - whyNoLint
87+ # - wrapperFunc
88+ # - yodaStyleExpr
89+ settings :
90+ ruleguard :
91+ failOn : all
92+ rules : " ${configDir}/scripts/rules.go"
93+
94+ staticcheck :
95+ # https://staticcheck.io/docs/options#checks
96+ # We disable SA1019 because it gets angry about our usage of xerrors. We
97+ # intentionally xerrors because stack frame support didn't make it into the
98+ # stdlib port.
99+ checks : ["all", "-SA1019"]
100+
101+ goimports :
102+ local-prefixes : coder.com,cdr.dev,go.coder.com,github.com/cdr,github.com/coder
103+
104+ importas :
105+ no-unaliased : true
106+
107+ misspell :
108+ locale : US
109+ ignore-words :
110+ - trialer
111+
112+ nestif :
113+ # goal: 10
114+ min-complexity : 20
115+
116+ revive :
117+ # see https://github.com/mgechev/revive#available-rules for details.
118+ ignore-generated-header : true
119+ severity : warning
120+ rules :
121+ - name : atomic
122+ - name : bare-return
123+ - name : blank-imports
124+ - name : bool-literal-in-expr
125+ - name : call-to-gc
126+ - name : confusing-naming
127+ - name : confusing-results
128+ - name : constant-logical-expr
129+ - name : context-as-argument
130+ - name : context-keys-type
131+ - name : deep-exit
132+ - name : defer
133+ - name : dot-imports
134+ - name : duplicated-imports
135+ - name : early-return
136+ - name : empty-block
137+ - name : empty-lines
138+ - name : error-naming
139+ - name : error-return
140+ - name : error-strings
141+ - name : errorf
142+ - name : exported
143+ - name : flag-parameter
144+ - name : get-return
145+ - name : identical-branches
146+ - name : if-return
147+ - name : import-shadowing
148+ - name : increment-decrement
149+ - name : indent-error-flow
150+ # - name: modifies-parameter
151+ - name : modifies-value-receiver
152+ - name : package-comments
153+ - name : range
154+ - name : receiver-naming
155+ - name : redefines-builtin-id
156+ - name : string-of-int
157+ - name : struct-tag
158+ - name : superfluous-else
159+ - name : time-naming
160+ - name : unconditional-recursion
161+ - name : unexported-naming
162+ - name : unexported-return
163+ - name : unhandled-error
164+ - name : unnecessary-stmt
165+ - name : unreachable-code
166+ - name : unused-parameter
167+ exclude : " **/*_test.go"
168+ - name : unused-receiver
169+ - name : var-declaration
170+ - name : var-naming
171+ - name : waitgroup-by-value
172+
173+ # irrelevant as of Go v1.22: https://go.dev/blog/loopvar-preview
174+ govet :
175+ disable :
176+ - loopclosure
177+ gosec :
178+ excludes :
179+ # Implicit memory aliasing of items from a range statement (irrelevant as of Go v1.22)
180+ - G601
181+
182+ issues :
183+ exclude-dirs :
184+ - coderd/database/dbmem
185+ - node_modules
186+ - .git
187+
188+ exclude-files :
189+ - scripts/rules.go
190+
191+ # Rules listed here: https://github.com/securego/gosec#available-rules
192+ exclude-rules :
193+ - path : _test\.go
194+ linters :
195+ # We use assertions rather than explicitly checking errors in tests
196+ - errcheck
197+ - forcetypeassert
198+ - exhaustruct # This is unhelpful in tests.
199+ - path : scripts/*
200+ linters :
201+ - exhaustruct
202+ - path : scripts/rules.go
203+ linters :
204+ - ALL
205+
206+ fix : true
207+ max-issues-per-linter : 0
208+ max-same-issues : 0
209+
210+ run :
211+ timeout : 10m
212+
213+ # Over time, add more and more linters from
214+ # https://golangci-lint.run/usage/linters/ as the code improves.
215+ linters :
216+ disable-all : true
217+ enable :
218+ - asciicheck
219+ - bidichk
220+ - bodyclose
221+ - dogsled
222+ - errcheck
223+ - errname
224+ - errorlint
225+ - exhaustruct
226+ - forcetypeassert
227+ - gocritic
228+ # gocyclo is may be useful in the future when we start caring
229+ # about testing complexity, but for the time being we should
230+ # create a good culture around cognitive complexity.
231+ # - gocyclo
232+ - gocognit
233+ - nestif
234+ - goimports
235+ - gomodguard
236+ - gosec
237+ - gosimple
238+ - govet
239+ - importas
240+ - ineffassign
241+ - makezero
242+ - misspell
243+ - nilnil
244+ - noctx
245+ - paralleltest
246+ - revive
247+
248+ # These don't work until the following issue is solved.
249+ # https://github.com/golangci/golangci-lint/issues/2649
250+ # - rowserrcheck
251+ # - sqlclosecheck
252+ # - structcheck
253+ # - wastedassign
254+
255+ - staticcheck
256+ - tenv
257+ # In Go, it's possible for a package to test it's internal functionality
258+ # without testing any exported functions. This is enabled to promote
259+ # decomposing a package before testing it's internals. A function caller
260+ # should be able to test most of the functionality from exported functions.
261+ #
262+ # There are edge-cases to this rule, but they should be carefully considered
263+ # to avoid structural inconsistency.
264+ - testpackage
265+ - tparallel
266+ - typecheck
267+ - unconvert
268+ - unused
269+ - dupl
0 commit comments