-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy path.golangci.yaml
More file actions
178 lines (155 loc) · 4.43 KB
/
.golangci.yaml
File metadata and controls
178 lines (155 loc) · 4.43 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
# Copyright (c) 2026, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
version: "2"
# Run configuration
run:
go: "1.26"
timeout: 5m
tests: true
modules-download-mode: readonly
# Output configuration
output:
formats:
text:
path: stdout
print-linter-name: true
print-issued-lines: true
colors: true
sort-order:
- linter
- severity
- file
linters:
enable:
# Bug detection
- bodyclose # HTTP response body must be closed
- copyloopvar # Loop variable capture issues (Go 1.22+)
- errorlint # Error wrapping and comparison
# - nilerr # Return nil after error check (disabled: intentional nil returns for skippable errors)
- nilnil # Nil/nil returns
- staticcheck # Advanced static analysis
# Code quality
- asciicheck # Non-ASCII identifiers
- dogsled # Too many blank identifiers
- dupl # Duplicate code detection
- exhaustive # Enum exhaustiveness
- funlen # Function length
# - gocognit # Cognitive complexity (disabled: existing code exceeds threshold)
- goconst # Repeated strings
- gocritic # Opinionated checks
- govet # Go vet checks
- misspell # Spelling
- nakedret # Naked returns
- prealloc # Slice preallocation
- revive # Golint replacement
- unconvert # Unnecessary conversions
- unparam # Unused parameters
- whitespace # Whitespace issues
# Security
- gosec # Security checks
# HTTP/Context
- contextcheck # Context propagation in function calls
- noctx # HTTP requests without context
# Dependency management
- depguard # Ban deprecated/unwanted packages
# Testing
- tparallel # t.Parallel() usage
# Style
- importas # Import aliasing
settings:
gosec:
excludes:
- G706 # Log injection: slog structured logging with key-value pairs is safe
funlen:
lines: 200
statements: 70
ignore-comments: true
gocognit:
min-complexity: 20
govet:
enable:
- shadow
misspell:
mode: restricted
locale: US
ignore-rules:
- Lustre
unparam:
check-exported: true
whitespace:
multi-if: true
multi-func: true
dupl:
threshold: 200
revive:
rules:
# Disable stuttering check - collector types intentionally include package name
# for clarity when used together (e.g., gpu.GPUCollector, grub.GrubCollector)
- name: exported
disabled: false
arguments:
- disableStutteringCheck
depguard:
rules:
main:
list-mode: lax
deny:
- pkg: io/ioutil
desc: "Deprecated since Go 1.16. Use io and os packages instead."
- pkg: math/rand$
desc: "Use math/rand/v2 for new code, or crypto/rand for security-sensitive code."
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
# Relaxed rules for test files
- linters:
- dupl
- errcheck
- funlen
- gocognit
- gocyclo
- gosec
- noctx
path: _test\.go
# SA5011 false positive: staticcheck doesn't know t.Fatal stops execution
- linters:
- staticcheck
text: "SA5011"
path: _test\.go
# Relaxed rules for main entry points
- linters:
- funlen
path: cmd/.*/main\.go
paths:
- third_party$
- builtin$
- examples$
issues:
max-issues-per-linter: 0
max-same-issues: 0
formatters:
enable:
- gofmt
- goimports
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$