-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.golangci.yaml
More file actions
176 lines (173 loc) · 6.6 KB
/
Copy path.golangci.yaml
File metadata and controls
176 lines (173 loc) · 6.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
version: "2"
run:
timeout: 5m
tests: true
modules-download-mode: readonly
linters:
default: standard
enable:
- bodyclose
- noctx
- gosec
- gocritic
- revive
- goconst
- gocyclo
- gocognit
- dupl
- unconvert
- unparam
- prealloc
- wastedassign
- intrange
- modernize
- usestdlibvars
- usetesting
- perfsprint
- misspell
- durationcheck
- errname
- nolintlint
- sloglint
settings:
errcheck:
check-type-assertions: true
govet:
enable-all: true
gocritic:
enabled-tags:
- diagnostic
- style
- performance
gocyclo:
# Cyclomatic complexity ~= the minimum number of test cases needed to
# cover every path, so it doubles as a "how much test does this need"
# signal. Tightened 18 -> 15 toward McCabe's limit (10), pragmatically
# raised for Go since each `if err != nil` adds a path.
min-complexity: 15
gocognit:
# Cognitive complexity (SonarQube's standard ceiling of 15) measures how
# hard a function is to understand, the better defect-density signal.
# Flat switches and sequential error checks that inflate gocyclo stay low
# here; a genuinely path-heavy-but-flat function may carry an explained
# //nolint:gocyclo (nolintlint requires the explanation).
min-complexity: 15
dupl:
# Cross-file duplication was the one quality axis nothing measured. The
# tool's default of 150 tokens over-fires on idiomatic Go (error-handling
# chains, flat switch bodies); 200 was chosen by measurement, not taste.
# VALIDATED AGAINST KNOWN FINDINGS before being enabled, which the fleet's
# vacuous-gate rule requires: at 200 with tests exempt a sweep of 37 Go
# repos reported exactly 2 findings, both the insertLines/deleteLines pair
# in web-terminal-engine/vt/csi.go. Those were resolved by extracting the
# shared prologue (prepareLineShift), and the fleet then measured clean.
# So this gate now guards against future drift rather than clearing a
# backlog. Duplication is genuinely rare here; do not read a green result
# as the linter being broken. Tests are exempt below for the same reason
# gocyclo/gocognit are: table-driven subtests are structurally repetitive
# by design.
threshold: 200
goconst:
ignore-tests: true
perfsprint:
strconcat: false
sloglint:
kv-only: true
nolintlint:
require-explanation: true
require-specific: true
exclusions:
presets:
# `comments` preset removed: revive's `exported` (every exported symbol
# needs a doc comment starting with its name) and `package-comments`
# (every package needs a doc comment) are now enforced org-wide.
# All consumer repos were updated before this change was propagated.
- std-error-handling
- common-false-positives
- legacy
paths:
- node_modules
rules:
# Tests are exempt from style/correctness linters (placeholder secrets,
# deliberate error-ignores, repeated literals) AND from complexity
# (gocyclo + gocognit). Both over-fire on idiomatic Go test code: a
# thorough table-driven / property / fuzz test is a loop + t.Run closures
# + per-case assertion guards, which gocognit's nesting model scores high
# without that being a smell. A 2026-06 audit put clean gold-standard
# libraries' flagship tests at cognitive 36-72 (atomicfile TestPendingFile
# is 72) and ~320 test funcs org-wide over 15; gating those would force
# ~320 //nolint or the splitting of cohesive table tests, degrading the
# suites. golangci also can't set a test-only threshold (min-complexity is
# global), so the prod gate of 15 can't coexist with a lenient test bar.
# Test complexity is judged in context instead: the test-review agent's
# smell catalog (Eager Test, Conditional Test Logic) plus human review.
- path: _test\.go
linters:
- dupl
- gocyclo
- gocognit
- errcheck
- gosec
- goconst
- gocritic
- govet
- prealloc
- perfsprint
- errname
- sloglint
- unparam
- usetesting
- noctx
- revive
- path: _test\.go
text: "string .* has .* occurrences"
linters:
- goconst
# Formatters (golangci-lint v2). `golangci-lint run` reports unformatted
# files as issues (exit 1), so the existing lint step enforces these — no
# extra workflow step / version bump needed; the config propagates via
# sync.yaml. `golangci-lint fmt` applies them.
formatters:
enable:
- gofumpt
- gci
settings:
gofumpt:
# Strictest: every `extra` rule, on top of gofumpt's strict superset of
# gofmt. module-path is auto-detected from each repo's go.mod when left
# empty.
#
# Named individually rather than via the old `extra-rules: true`
# catch-all, which golangci-lint deprecates (it warns on every run) and
# which will be removed. The three keys below are exactly what
# `extra-rules: true` enabled, so this migration changes no formatting.
#
# Upstream deliberately offers NO replacement "all" switch: enabling each
# rule is meant to be a conscious choice so new rules cannot silently
# reformat every repo. The consequence to know is that a future gofumpt
# rule will NOT arrive here automatically and has to be added on purpose.
extra:
# Group adjacent function parameters that share a type.
group-params: true
# Clothe naked returns in functions with named results.
clothe-returns: true
# Put a multi-line call's closing paren on its own line when the
# opening paren ends a line.
balance-calls: true
gci:
# Deterministic import grouping: standard -> third-party -> local
# module (folded by gofumpt into the third-party group). A separate
# gci `localmodule`/`prefix` section is intentionally NOT used: gofumpt
# never emits a distinct local-import group, so it would never converge.
# goimports is intentionally NOT enabled: it conflicts with gci on
# ordering, and its only unique capability (add/remove imports) is
# moot in CI — the Go compiler already rejects unused/missing
# imports, and editors handle it via gopls.
sections:
- standard
- default
custom-order: true
exclusions:
# Generated files are auto-excluded (default generated: lax).
paths:
- node_modules