-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.golangci.yml
More file actions
201 lines (176 loc) · 5.75 KB
/
Copy path.golangci.yml
File metadata and controls
201 lines (176 loc) · 5.75 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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
version: "2"
########################
# 1. Execution settings
########################
run:
timeout: 5m # Keep the original timeout
tests: true # Analyze *_test.go files as well
issues-exit-code: 1 # Fail CI if any issue is found
go: "1.25" # Ensure 1.22+ analyses (intrange, copyloopvar) run with new semantics
########################
# 2. Issues quota
########################
issues:
max-issues-per-linter: 0 # Do not cap issues per linter
max-same-issues: 0 # Do not deduplicate identical issues
########################
# 3. Enabled linters
########################
linters:
default: none
enable:
# Core correctness & security
- govet
- staticcheck
- errcheck
- ineffassign
- unused
- errchkjson
- errorlint
- gosec
- goconst
- gocritic
- mnd
- revive
- unparam
- unconvert
- bodyclose
- asasalint
- misspell
- usestdlibvars
- testifylint
- perfsprint
- paralleltest
- tagliatelle
- thelper
- testpackage
# Modernization related to Go 1.22–1.25
- intrange # Prefer `for i := range n` where applicable (Go 1.22) [external linter]
- copyloopvar # Detect legacy loop-var copies; has autofix
- exptostd # Suggest std replacements for x/exp/*
# Logging hygiene (slog)
- sloglint # Enforce consistent slog usage
- loggercheck # Validate slog key/value shapes
# API/style consistency that reduces long-term churn
- nilnesserr # Detect inconsistent nil/err returns
- predeclared # Avoid shadowing predeclared identifiers
- godot # Enforce periods at the end of doc comments
- whitespace # Normalize whitespace
- fatcontext # Avoid capturing/propagating "fat" contexts
- nosprintfhostport # Safer host:port formatting
- depguard # Belt-and-suspenders dependency rules
########################
# 4. Per-linter settings
# https://golangci-lint.run/docs/linters/configuration/
########################
settings:
errcheck:
check-type-assertions: true
check-blank: true
staticcheck:
checks:
- all
- "-SA1012"
errchkjson:
check-error-free-encoding: true
errorlint:
errorf: true
asserts: true
goconst:
min-len: 2
min-occurrences: 3
gocritic:
enable-all: true
disabled-checks:
- hugeParam
- rangeValCopy
- commentedOutCode
- whyNoLint
- importShadow # Disable to avoid churn in legacy code
- paramTypeCombine # Disable to avoid cosmetic changes
gosec:
excludes:
- G101 # Exclude hardcoded credentials check (false positives in env var names)
- G304 # Exclude file inclusion check (necessary for dynamic file operations)
mnd:
checks: [argument,assign,case,return]
ignored-functions: ["time.Duration"]
revive:
confidence: 0.8
rules:
- name: indent-error-flow
arguments: [preserveScope]
- name: function-length
arguments: [80, 0]
- name: error-strings
- name: error-naming
- name: var-naming
arguments:
# White List to preserve readability. I maintain these words by hands.
- [
# Network Protocols & Technologies
"SSH", "Telnet", "TCP", "IP", "TLS", "DTLS", "CLI", "OS",
# Network Vendors & Platforms
"IOS", "NXOS", "ASA", "AireOS", "JunOS", "ScreenOS", "SRX", "SSG", "Yamaha",
# Network Devices & Components
"AP", "VLAN", "MAC", "SSID"
]
# Black List to avoid confusion with common initialisms.
- [
# General
"API", "ID", "URL", "URI", "UUID", "HTTP", "HTTPS",
# Network Protocols
"DHCP", "DNS", "SNMP", "NTP", "RADIUS", "TACACS"
]
- - skip-initialism-name-checks: false
misspell:
locale: US
perfsprint:
int-conversion: true
err-error: true
errorf: true
sprintf1: true
paralleltest:
ignore-missing: false
tagliatelle:
case:
rules:
json: snake
testifylint:
enable-all: true
disable:
- float-compare
govet:
enable-all: true
disable:
- shadow # Prevent noisy false positives
- fieldalignment # Avoid churn with marginal benefits
sloglint: # See options: https://github.com/go-simpler/sloglint
no-mixed-args: true # Do not mix key/value pairs and Attrs
no-global: "" # Allow default global logger usage for simplicity
copyloopvar:
check-alias: true # Also flag aliasing the loop variable
depguard:
rules:
main:
list-mode: lax
files: [ $all ]
allow:
- $gostd
deny:
- pkg: "log$"
desc: "Use slog (and sloglint) instead of log package"
- pkg: "golang.org/x/exp/maps$"
desc: "Use std `maps` and built-ins (e.g., clear) instead of x/exp/maps"
- pkg: "golang.org/x/exp/slices$"
desc: "Use std `slices` instead of x/exp/slices"
- pkg: "github.com/pkg/errors$"
desc: "Use std `errors`"
- pkg: "math/rand$"
desc: "Use `math/rand/v2` on Go 1.22+"
########################
# 5. Exclusions
########################
exclusions:
generated: lax
warn-unused: false