-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.golangci.yml
More file actions
262 lines (227 loc) · 8.84 KB
/
.golangci.yml
File metadata and controls
262 lines (227 loc) · 8.84 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
262
# GolangCI-Lint v2.5 Configuration for PubSub-Go Library
# Documentation: https://golangci-lint.run/docs/configuration/
# AGGRESSIVE CONFIGURATION - Catches more issues during development
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
- 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 # Check comments end in periods
# 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:
govet:
# EXPLICITLY ENABLE copylocks to catch mutex copying issues
enable:
- copylocks
# Disable fieldalignment (memory optimization not critical)
disable:
- fieldalignment
gocyclo:
# Lower threshold for production code
min-complexity: 15
cyclop:
# Max complexity
max-complexity: 15
funlen:
# Allow reasonably long functions for pub/sub business logic
lines: 120
statements: 60
gocognit:
# Cognitive complexity threshold
min-complexity: 20
misspell:
locale: US
nestif:
# Max nesting level
min-complexity: 4
revive:
# Enable important rules for code quality
rules:
- name: var-naming
- name: exported
- name: error-return
- name: error-naming
- name: if-return
- name: increment-decrement
- name: var-declaration
- name: package-comments
- name: range
- name: receiver-naming
- name: time-naming
- name: unexported-return
- name: indent-error-flow
- name: errorf
- name: empty-block
- name: superfluous-else
- name: unused-parameter
- name: unreachable-code
- name: redefines-builtin-id
gocritic:
# Enable important checks
enabled-tags:
- diagnostic
- style
- 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
settings:
hugeParam:
# Domain models can be large (Queue, DeadLetterQueue, etc.)
# Default is 80 bytes, allow larger structs for domain models
sizeThreshold: 256
# Exclusions (v2 structure: linters.exclusions.rules)
exclusions:
rules:
- path: _test\.go
linters:
- gocyclo
- cyclop
- funlen
- maintidx
- errcheck
- gosec
- goconst
- dupl
# internal/utils - utility package name is acceptable
- path: internal/utils/.*\.go
linters:
- revive # Skip package naming rules
text: "var-naming: avoid meaningless package names"
- path: ".*\\.pb\\.go" # Generated files
linters:
- revive
- gocritic
# internal/deprecated/ - legacy code scheduled for removal
- path: internal/deprecated/
linters:
- revive
- godot
- gocritic
- gosec
- gochecknoglobals
# cmd/ - utility programs can be less strict
- path: cmd/.*\.go
linters:
- gocognit # Command-line tools can be complex
- nestif # CLI logic acceptable
- funlen # Main functions can be longer
- gocyclo # CLI complexity acceptable
- cyclop # CLI complexity acceptable
- godot # Command output formatting
- gosec # CLI file operations acceptable
- gocritic # CLI patterns acceptable
# Queue worker - batch processing and retry logic
- path: queue_worker\.go
linters:
- funlen # Worker methods handle complex batch processing
- gocyclo # Retry logic branching
- cyclop # Delivery attempt complexity
- nestif # Error handling nesting
- gocognit # Complex retry orchestration
# Publisher - message routing logic
- path: publisher\.go
linters:
- funlen # Publishing logic with subscription routing
- gocyclo # Topic/subscription branching
- cyclop # Queue creation complexity
- nestif # Validation and routing nesting
- gocognit # Complex publishing flow
# Subscription manager - lifecycle management
- path: subscription_manager\.go
linters:
- funlen # Subscription CRUD operations
- gocyclo # Validation branching
- cyclop # State management complexity
- nestif # Validation nesting
- gocognit # Complex lifecycle logic
# Relica adapters - repository implementations
- path: adapters/relica/.*\.go
linters:
- funlen # Repository methods with complex queries
- gocyclo # Query building branching
- cyclop # Database operation complexity
- nestif # Error handling nesting
- gocognit # Complex query construction
# Model validation - domain business logic
- path: model/queue\.go
linters:
- funlen # Queue domain model with business logic
- gocyclo # State machine branching
- cyclop # Retry decision complexity
- nestif # State validation nesting
- gocognit # Complex domain rules
# Migrations - database schema evolution
- path: migrations/.*\.go
linters:
- funlen # Migration SQL can be long
- gocyclo # Version detection branching
- cyclop # Schema complexity
- gosec # SQL strings are expected
- goconst # SQL duplication acceptable
# Examples - demonstration code can be verbose
# Multiple main() functions in examples/ is expected (each is standalone)
- 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
- typecheck # Skip typecheck for examples (multiple main)
- 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
issues:
# Show all issues
max-issues-per-linter: 0
max-same-issues: 0
# Don't hide new issues in existing files
new: false