Skip to content

Commit 952985c

Browse files
committed
feat: alignt lint check with coder/coder
1 parent 4e7fcf3 commit 952985c

5 files changed

Lines changed: 375 additions & 2 deletions

File tree

.golangci.yaml

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
# Based on the Coder repo lint profile, trimmed to the checks that make sense
2+
# for the standalone aibridge module.
3+
4+
linters-settings:
5+
dupl:
6+
threshold: 412
7+
8+
exhaustruct:
9+
include:
10+
- 'httpmw\.\w+'
11+
12+
gocognit:
13+
min-complexity: 300
14+
15+
goconst:
16+
min-len: 4
17+
min-occurrences: 3
18+
19+
gocritic:
20+
enabled-checks:
21+
- badLock
22+
- badRegexp
23+
- boolExprSimplify
24+
- builtinShadowDecl
25+
- commentedOutImport
26+
- deferUnlambda
27+
- dupImport
28+
- emptyFallthrough
29+
- hexLiteral
30+
- indexAlloc
31+
- initClause
32+
- methodExprCall
33+
- nilValReturn
34+
- regexpPattern
35+
- ruleguard
36+
- sortSlice
37+
- sprintfQuotedString
38+
- sqlQuery
39+
- truncateCmp
40+
- typeAssertChain
41+
- weakCond
42+
settings:
43+
ruleguard:
44+
failOn: all
45+
rules: "${configDir}/scripts/rules.go"
46+
47+
staticcheck:
48+
checks: ["all", "-SA1019"]
49+
50+
goimports:
51+
local-prefixes: coder.com,cdr.dev,go.coder.com,github.com/cdr,github.com/coder
52+
53+
importas:
54+
no-unaliased: true
55+
56+
misspell:
57+
locale: US
58+
ignore-words:
59+
- trialer
60+
61+
nestif:
62+
min-complexity: 20
63+
64+
revive:
65+
ignore-generated-header: true
66+
severity: warning
67+
rules:
68+
- name: atomic
69+
- name: bare-return
70+
- name: blank-imports
71+
- name: bool-literal-in-expr
72+
- name: call-to-gc
73+
- name: confusing-naming
74+
- name: confusing-results
75+
- name: constant-logical-expr
76+
- name: context-as-argument
77+
- name: context-keys-type
78+
- name: deep-exit
79+
- name: defer
80+
- name: dot-imports
81+
- name: duplicated-imports
82+
- name: early-return
83+
- name: empty-block
84+
- name: empty-lines
85+
- name: error-naming
86+
- name: error-return
87+
- name: error-strings
88+
- name: errorf
89+
- name: exported
90+
- name: flag-parameter
91+
- name: get-return
92+
- name: identical-branches
93+
- name: if-return
94+
- name: import-shadowing
95+
- name: increment-decrement
96+
- name: indent-error-flow
97+
- name: modifies-value-receiver
98+
- name: package-comments
99+
- name: range
100+
- name: receiver-naming
101+
- name: redefines-builtin-id
102+
- name: string-of-int
103+
- name: struct-tag
104+
- name: superfluous-else
105+
- name: time-naming
106+
- name: unconditional-recursion
107+
- name: unexported-naming
108+
- name: unexported-return
109+
- name: unhandled-error
110+
- name: unnecessary-stmt
111+
- name: unreachable-code
112+
- name: unused-parameter
113+
exclude: "**/*_test.go"
114+
- name: unused-receiver
115+
- name: var-declaration
116+
- name: var-naming
117+
- name: waitgroup-by-value
118+
119+
usetesting:
120+
os-setenv: true
121+
os-create-temp: false
122+
os-mkdir-temp: false
123+
os-temp-dir: false
124+
os-chdir: false
125+
context-background: false
126+
context-todo: false
127+
128+
govet:
129+
disable:
130+
- loopclosure
131+
132+
gosec:
133+
excludes:
134+
- G601
135+
136+
issues:
137+
fix: true
138+
139+
exclude-dirs:
140+
- .git
141+
142+
exclude-files:
143+
- scripts/rules.go
144+
145+
exclude-rules:
146+
- path: _test\.go
147+
linters:
148+
- errcheck
149+
- forcetypeassert
150+
- exhaustruct
151+
- path: scripts/*
152+
linters:
153+
- exhaustruct
154+
- path: scripts/rules.go
155+
linters:
156+
- ALL
157+
158+
max-issues-per-linter: 0
159+
max-same-issues: 0
160+
161+
run:
162+
timeout: 10m
163+
164+
linters:
165+
disable-all: true
166+
enable:
167+
- asciicheck
168+
- bidichk
169+
- bodyclose
170+
- dogsled
171+
- errcheck
172+
- errname
173+
- errorlint
174+
- exhaustruct
175+
- forcetypeassert
176+
- gocognit
177+
- gocritic
178+
- goimports
179+
- gomodguard
180+
- gosec
181+
- gosimple
182+
- govet
183+
- importas
184+
- ineffassign
185+
- makezero
186+
- misspell
187+
- nestif
188+
- nilnil
189+
- noctx
190+
- paralleltest
191+
- revive
192+
- staticcheck
193+
- testpackage
194+
- tparallel
195+
- typecheck
196+
- unconvert
197+
- unused
198+
- usetesting
199+
- dupl

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ ifndef VERBOSE
1414
endif
1515

1616
SHELL_SRC_FILES := $(shell find . -type f -name '*.sh' -not -path '*/.git/*')
17-
GOLANGCI_LINT_VERSION ?= 2.11.4
17+
GOLANGCI_LINT_VERSION ?= 1.64.8
1818
PARALLELTESTCTX_VERSION ?= 0.0.1
1919

2020
lint: lint/shellcheck lint/go
2121
.PHONY: lint
2222

2323
lint/go:
24-
go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v$(GOLANGCI_LINT_VERSION) run
24+
go run github.com/golangci/golangci-lint/cmd/golangci-lint@v$(GOLANGCI_LINT_VERSION) run
2525
go run github.com/coder/paralleltestctx/cmd/paralleltestctx@v$(PARALLELTESTCTX_VERSION) -custom-funcs="testutil.Context" ./...
2626
.PHONY: lint/go
2727

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ require (
7575
github.com/prometheus/client_model v0.6.2 // indirect
7676
github.com/prometheus/common v0.66.1 // indirect
7777
github.com/prometheus/procfs v0.16.1 // indirect
78+
github.com/quasilyte/go-ruleguard/dsl v0.3.23 // indirect
7879
github.com/rivo/uniseg v0.4.4 // indirect
7980
github.com/spf13/cast v1.7.1 // indirect
8081
github.com/tidwall/match v1.2.0 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ github.com/prometheus/common v0.66.1 h1:h5E0h5/Y8niHc5DlaLlWLArTQI7tMrsfQjHV+d9Z
106106
github.com/prometheus/common v0.66.1/go.mod h1:gcaUsgf3KfRSwHY4dIMXLPV0K/Wg1oZ8+SbZk/HH/dA=
107107
github.com/prometheus/procfs v0.16.1 h1:hZ15bTNuirocR6u0JZ6BAHHmwS1p8B4P6MRqxtzMyRg=
108108
github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is=
109+
github.com/quasilyte/go-ruleguard/dsl v0.3.23 h1:lxjt5B6ZCiBeeNO8/oQsegE6fLeCzuMRoVWSkXC4uvY=
110+
github.com/quasilyte/go-ruleguard/dsl v0.3.23/go.mod h1:KeCP03KrjuSO0H1kTuZQCWlQPulDV6YMIXmpQss17rU=
109111
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
110112
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
111113
github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=

0 commit comments

Comments
 (0)