-
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy path.golangci.yml.backup
More file actions
203 lines (175 loc) · 6.65 KB
/
Copy path.golangci.yml.backup
File metadata and controls
203 lines (175 loc) · 6.65 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
# GolangCI-Lint v2.5 Configuration for Cortex HTTP Router
# Documentation: https://golangci-lint.run/docs/configuration/
# Copied from: github.com/scigolib/matlab (reference project)
# 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 routing 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:
# Router structures can be large (context, handlers)
# Default is 80 bytes, allow larger structs for HTTP handling
sizeThreshold: 256
# Exclusions (v2 structure: linters.exclusions.rules)
exclusions:
rules:
- path: _test\.go
linters:
- gocyclo
- cyclop
- funlen
- maintidx
- errcheck
- gosec
- goconst
- dupl
- path: ".*\\.pb\\.go" # Generated files
linters:
- revive
- gocritic
# cmd/ and scripts/ - utility programs can be less strict
- path: (cmd|scripts)/.*\.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
# internal/radix - complex routing algorithm (radix tree)
- path: internal/radix/.*\.go
linters:
- funlen # Routing algorithms naturally longer
- gocyclo # Radix tree complexity
- cyclop # Tree traversal complexity
- nestif # Tree logic nesting
- gocognit # Complex routing logic
# 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