-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path.golangci.yml
More file actions
261 lines (224 loc) · 8.96 KB
/
Copy path.golangci.yml
File metadata and controls
261 lines (224 loc) · 8.96 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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# GolangCI-Lint v2.5 Configuration for coregex - High-Performance Regex Engine
# Documentation: https://golangci-lint.run/docs/configuration/
# AGGRESSIVE CONFIGURATION - Production-quality regex engine with SIMD optimizations
version: "2"
run:
timeout: 5m
tests: true
linters:
# Enable comprehensive set of linters for production-quality code
enable:
# Code quality and complexity
- gocyclo # Check cyclomatic complexity
- gocognit # Check cognitive complexity
- funlen # Check function length
- maintidx # Maintainability index
- cyclop # Check cyclomatic complexity (alternative)
- nestif # Reports deeply nested if statements
# Bug detection
- govet # Standard Go vet (includes copylocks!)
- staticcheck # Comprehensive static analysis
- errcheck # Check that errors are handled
- errorlint # Check error wrapping
- gosec # Security issues
- nilnil # Check that functions don't return nil both ways
- nilerr # Check nil error returns
- nilnesserr # Check nil error returns patterns
- ineffassign # Detect ineffectual assignments
# Code style and consistency
- misspell # Check for misspelled words
- whitespace # Check for trailing whitespace
- unconvert # Remove unnecessary type conversions
- unparam # Detect unused function parameters
# Naming conventions
- errname # Check error naming conventions
- revive # Fast, configurable, extensible linter
# Performance (critical for regex engine)
- prealloc # Find slice declarations that could be preallocated
- bodyclose # Check HTTP response bodies are closed
- makezero # Find slice declarations with non-zero initial length
# Code practices
- goconst # Find repeated strings that could be constants
- gocritic # Comprehensive code checker
- goprintffuncname # Check printf-like function names
- nolintlint # Check nolint directives are used correctly
- nakedret # Checks for naked returns
# Comments and documentation
# godot disabled - too pedantic for internal comments
# godox disabled - TODO comments are acceptable during development
# Additional quality checkers
- dupl # Detect duplicate code
- dogsled # Check for assignments with too many blank identifiers
- durationcheck # Check for two durations multiplied together
settings:
gosec:
# Exclude rules that produce false positives in regex engine code:
# G101: false positive on strategyReasons map (not credentials)
# G115: rune->byte conversions in UTF-8 encoding are bounded by design
# G602: slice accesses in range-checked loops are safe
excludes:
- G101
- G115
- G602
govet:
# EXPLICITLY ENABLE copylocks to catch mutex copying issues
# Critical for DFA cache and concurrent regex matching
enable:
- copylocks
# Disable fieldalignment (memory optimization handled manually for hot paths)
disable:
- fieldalignment
gocyclo:
# Regex algorithms (DFA construction, NFA simulation) can be complex
# But keep it reasonable - refactor if exceeding this
min-complexity: 25
cyclop:
# Regex algorithms need higher threshold
max-complexity: 25
funlen:
# SIMD assembly wrappers and DFA search can be long
lines: 150
statements: 80
gocognit:
# Regex engine algorithms are complex but should be understandable
min-complexity: 40
misspell:
locale: US
nestif:
# Max nesting level - keep regex code readable
min-complexity: 4
revive:
# Enable important rules for code quality
rules:
- name: var-naming
- name: error-return
- name: error-naming
- name: if-return
- name: increment-decrement
- name: var-declaration
- name: range
- name: receiver-naming
- name: time-naming
- name: unexported-return
- name: indent-error-flow
- name: errorf
- name: empty-block
- name: superfluous-else
- name: unreachable-code
- name: redefines-builtin-id
# Disabled: exported (stuttering OK for regex types like DFAState)
# Disabled: package-comments (internal packages don't need)
# Disabled: unused-parameter (regex funcs may have standard signatures)
gocritic:
# Enable important checks
enabled-tags:
- diagnostic
- style
- performance # Critical for regex engine performance
# Disable overly opinionated/experimental checks
disabled-checks:
- commentFormatting # Too opinionated about comment style
- whyNoLint # We document nolints when needed
- unnamedResult # Named results can reduce readability
- commentedOutCode # False positives on test data comments
- octalLiteral # 0644 is clearer than 0o644 for file perms
- paramTypeCombine # Explicit types clearer in regex code
settings:
hugeParam:
# Regex structs can be large (DFA states, cache, NFA)
sizeThreshold: 256
# Exclusions (v2 structure: linters.exclusions.rules)
exclusions:
rules:
# Test files - allow more flexibility
- path: _test\.go
linters:
- gocyclo
- cyclop
- funlen
- maintidx
- errcheck
- gosec
- goconst
- dupl
- gocognit
# SIMD assembly wrappers - can be complex
- path: simd/memchr.*\.go
linters:
- gocyclo # Assembly dispatch logic
- funlen # SIMD wrappers can be long
- gocognit # CPU feature detection complexity
# NFA/PikeVM - hot path with intentional duplication
- path: nfa/pikevm\.go
linters:
- dupl # addThreadForMatch/addThreadToNextForMatch are intentionally duplicated
- nestif # Epsilon closure has nested conditions for performance
# DFA lazy construction - inherently complex
- path: dfa/lazy/.*\.go
linters:
- gocyclo # DFA construction is complex
- cyclop # DFA determinization complexity
- gocognit # Determinization complexity
- nestif # DFA logic has nested conditions
# Prefilter selection - strategy pattern
- path: prefilter/selector\.go
linters:
- gocyclo # Strategy selection logic
- nestif # Decision tree for prefilter
# Meta-engine orchestration
- path: meta/.*\.go
linters:
- gocyclo # Engine selection complexity
- gocognit # Strategy orchestration
- nestif # Multi-engine decision logic
- funlen # CompileRegexp and other orchestration functions
# Literal extraction - complex heuristics
- path: literal/.*\.go
linters:
- gocyclo # Literal extraction heuristics
- gocognit # Pattern analysis complexity
# Internal utilities
- path: internal/.*\.go
linters:
- revive # Internal packages, skip naming rules
text: "var-naming: avoid meaningless package names"
# Generated files (if any)
- path: ".*\\.pb\\.go"
linters:
- revive
- gocritic
# Benchmark code - can be verbose
- path: benchmark/.*\.go
linters:
- funlen # Benchmark setups can be long
- gocyclo # Benchmark complexity acceptable
- errcheck # Benchmarks may skip error handling
- gosec # Benchmark file operations acceptable
# Example code - demonstration purposes
- path: examples?/.*\.go
linters:
- errcheck # Examples may skip error handling for clarity
- errorlint # Examples may use %v instead of %w
- funlen # Example functions can be longer
- gocyclo # Example complexity acceptable
- cyclop # Example complexity acceptable
- gocognit # Example complexity acceptable
- godot # Example comments don't need periods
- revive # Examples don't need full documentation
- gosec # Examples may have security warnings
- gocritic # Example patterns may differ
# Assembly files dispatcher - platform-specific
- path: .*_amd64\.go
linters:
- gocritic # Platform-specific patterns
text: "ifElseChain"
# SIMD functions may be used only in tests/benchmarks (not production)
- path: .*_amd64\.go
linters:
- unused # e.g., AVX2 not enabled in integrated prefilter (#74)
issues:
# Show all issues
max-issues-per-linter: 0
max-same-issues: 0
# Don't hide new issues in existing files
new: false