Skip to content

Commit fd7623c

Browse files
committed
add golang-ci lint (v2) based on coder/coder config
Signed-off-by: Callum Styan <[email protected]>
1 parent 5a3ade7 commit fd7623c

File tree

4 files changed

+504
-1
lines changed

4 files changed

+504
-1
lines changed

.golangci.yml

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
version: "2"
2+
linters:
3+
default: none
4+
enable:
5+
- asciicheck
6+
- bidichk
7+
- bodyclose
8+
- dogsled
9+
- dupl
10+
- errcheck
11+
- errname
12+
- errorlint
13+
- exhaustruct
14+
- forcetypeassert
15+
- gocognit
16+
- gocritic
17+
- godot
18+
- gomodguard
19+
- gosec
20+
- govet
21+
- importas
22+
- ineffassign
23+
- makezero
24+
- misspell
25+
- nestif
26+
- nilnil
27+
- noctx
28+
- paralleltest
29+
- revive
30+
- staticcheck
31+
- testpackage
32+
- tparallel
33+
- unconvert
34+
- unused
35+
settings:
36+
dupl:
37+
threshold: 412
38+
exhaustruct:
39+
include:
40+
- httpmw\.\w+
41+
- github.com/coder/coder/v2/coderd/database\.[^G][^e][^t]\w+Params
42+
gocognit:
43+
min-complexity: 300
44+
goconst:
45+
min-len: 4
46+
min-occurrences: 3
47+
gocritic:
48+
enabled-checks:
49+
- badLock
50+
- badRegexp
51+
- boolExprSimplify
52+
- builtinShadow
53+
- builtinShadowDecl
54+
- commentedOutImport
55+
- deferUnlambda
56+
- dupImport
57+
- dynamicFmtString
58+
- emptyDecl
59+
- emptyFallthrough
60+
- emptyStringTest
61+
- evalOrder
62+
- externalErrorReassign
63+
- filepathJoin
64+
- hexLiteral
65+
- httpNoBody
66+
- importShadow
67+
- indexAlloc
68+
- initClause
69+
- methodExprCall
70+
- nestingReduce
71+
- nilValReturn
72+
- preferFilepathJoin
73+
- rangeAppendAll
74+
- regexpPattern
75+
- redundantSprint
76+
- regexpSimplify
77+
- ruleguard
78+
- sliceClear
79+
- sortSlice
80+
- sprintfQuotedString
81+
- sqlQuery
82+
- stringConcatSimplify
83+
- stringXbytes
84+
- todoCommentWithoutDetail
85+
- tooManyResultsChecker
86+
- truncateCmp
87+
- typeAssertChain
88+
- typeDefFirst
89+
- unlabelStmt
90+
- weakCond
91+
- whyNoLint
92+
settings:
93+
ruleguard:
94+
failOn: all
95+
rules: ${base-path}/scripts/rules.go
96+
gosec:
97+
excludes:
98+
- G601
99+
govet:
100+
disable:
101+
- loopclosure
102+
importas:
103+
no-unaliased: true
104+
misspell:
105+
locale: US
106+
ignore-rules:
107+
- trialer
108+
nestif:
109+
min-complexity: 20
110+
revive:
111+
severity: warning
112+
rules:
113+
- name: atomic
114+
- name: bare-return
115+
- name: blank-imports
116+
- name: bool-literal-in-expr
117+
- name: call-to-gc
118+
- name: confusing-naming
119+
- name: confusing-results
120+
- name: constant-logical-expr
121+
- name: context-as-argument
122+
- name: context-keys-type
123+
- name: deep-exit
124+
- name: defer
125+
- name: dot-imports
126+
- name: duplicated-imports
127+
- name: early-return
128+
- name: empty-block
129+
- name: empty-lines
130+
- name: error-naming
131+
- name: error-return
132+
- name: error-strings
133+
- name: errorf
134+
- name: exported
135+
- name: flag-parameter
136+
- name: get-return
137+
- name: identical-branches
138+
- name: if-return
139+
- name: import-shadowing
140+
- name: increment-decrement
141+
- name: indent-error-flow
142+
- name: modifies-value-receiver
143+
- name: package-comments
144+
- name: range
145+
- name: receiver-naming
146+
- name: redefines-builtin-id
147+
- name: string-of-int
148+
- name: struct-tag
149+
- name: superfluous-else
150+
- name: time-naming
151+
- name: unconditional-recursion
152+
- name: unexported-naming
153+
- name: unexported-return
154+
- name: unhandled-error
155+
- name: unnecessary-stmt
156+
- name: unreachable-code
157+
- name: unused-parameter
158+
- name: unused-receiver
159+
- name: var-declaration
160+
- name: var-naming
161+
- name: waitgroup-by-value
162+
staticcheck:
163+
checks:
164+
- all
165+
- SA4006 # Detects redundant assignments
166+
- SA4009 # Detects redundant variable declarations
167+
- SA1019
168+
exclusions:
169+
generated: lax
170+
presets:
171+
- comments
172+
- common-false-positives
173+
- legacy
174+
- std-error-handling
175+
rules:
176+
- linters:
177+
- errcheck
178+
- exhaustruct
179+
- forcetypeassert
180+
path: _test\.go
181+
- linters:
182+
- exhaustruct
183+
path: scripts/*
184+
- linters:
185+
- ALL
186+
path: scripts/rules.go
187+
paths:
188+
- scripts/rules.go
189+
- coderd/database/dbmem
190+
- node_modules
191+
- .git
192+
- third_party$
193+
- builtin$
194+
- examples$
195+
issues:
196+
max-issues-per-linter: 0
197+
max-same-issues: 0
198+
fix: true
199+
formatters:
200+
enable:
201+
- goimports
202+
- gofmt
203+
exclusions:
204+
generated: lax
205+
paths:
206+
- scripts/rules.go
207+
- coderd/database/dbmem
208+
- node_modules
209+
- .git
210+
- third_party$
211+
- builtin$
212+
- examples$

go.mod

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@ module coder.com/coder-registry
22

33
go 1.23.2
44

5-
require gopkg.in/yaml.v3 v3.0.1
5+
require (
6+
github.com/quasilyte/go-ruleguard/dsl v0.3.22
7+
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da
8+
gopkg.in/yaml.v3 v3.0.1
9+
)

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
github.com/quasilyte/go-ruleguard/dsl v0.3.22 h1:wd8zkOhSNr+I+8Qeciml08ivDt1pSXe60+5DqOpCjPE=
2+
github.com/quasilyte/go-ruleguard/dsl v0.3.22/go.mod h1:KeCP03KrjuSO0H1kTuZQCWlQPulDV6YMIXmpQss17rU=
3+
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da h1:noIWHXmPHxILtqtCOPIhSt0ABwskkZKjD3bXGnZGpNY=
4+
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90=
15
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
26
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
37
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

0 commit comments

Comments
 (0)