-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.golangci.yml
More file actions
216 lines (194 loc) · 7.14 KB
/
Copy path.golangci.yml
File metadata and controls
216 lines (194 loc) · 7.14 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
# golangci-lint configuration
# https://golangci-lint.run/usage/configuration/
version: "2"
run:
timeout: 5m
tests: true
modules-download-mode: readonly
allow-parallel-runners: true
go: "1.26"
linters:
enable:
# Enabled by default
- errcheck # Check for unchecked errors
- govet # Standard Go vet
- ineffassign # Detect ineffectual assignments
- staticcheck # Staticcheck (SA*) - includes gosimple and stylecheck in v2
- unused # Check for unused constants, variables, functions and types
# Additional enabled linters
- asasalint # Check for pass []any as any in variadic func(...any)
- asciicheck # Check for non-ASCII identifiers
- bidichk # Check for dangerous unicode character sequences
- bodyclose # Check HTTP response body is closed
- contextcheck # Check context.Context is passed correctly
- dupl # Detect code duplication
- durationcheck # Check for common mistakes with time.Duration
- errname # Check error naming conventions
- errorlint # Find code that will cause problems with error wrapping
- exhaustive # Check exhaustiveness of enum switch statements
- copyloopvar # Check for pointers to enclosing loop variables (replaces exportloopref)
- forbidigo # Forbid specific identifiers
- gocheckcompilerdirectives # Check Go compiler directive comments
- gochecknoinits # Check no init functions
- gochecksumtype # Check exhaustiveness on sum types
- goconst # Find repeated strings that could be constants
- gocritic # Comprehensive Go checker
- gocyclo # Compute cyclomatic complexities
- godot # Check comment sentences end with period
- gomoddirectives # Manage replace/retract directives in go.mod
- gomodguard_v2 # Control allowed modules
- goprintffuncname # Check printf-like function names
- gosec # Security problems (G*)
- intrange # Find places where for loops could use Go 1.22+ integer range
- lll # Report long lines
- loggercheck # Check logger arguments
- makezero # Find slice declarations with non-zero initial length
- mirror # Detect wrong mirror usage
- misspell # Find commonly misspelled words
- musttag # Enforce field tags
- nakedret # Find naked returns in long functions
- nilerr # Find code returning nil even if error is checked
- nilnil # Check no simultaneous nil returns
- noctx # Find HTTP requests without context
- nolintlint # Ill-formed or ineffective nolint directives
- nonamedreturns # Reports named returns
- nosprintfhostport # Check no sprintf with host:port
- perfsprint # Check for performance issues with fmt.Sprintf
- predeclared # Find code that shadows predeclared identifiers
- promlinter # Check Prometheus metrics naming
- protogetter # Check for direct access to protobuf fields
- reassign # Check package-level variables are not reassigned
- revive # Fast linter with extensible rules
- rowserrcheck # Check errors from sql.Rows
- sloglint # Ensure consistent code style when using log/slog
- sqlclosecheck # Check sql.Rows and sql.Stmt are closed
- usetesting # Detect using os.Setenv instead of t.Setenv (replaces tenv)
- testableexamples # Check examples are testable
- testpackage # Require separate _test package
- thelper # Detect test helpers without t.Helper()
- tparallel # Detect inappropriate usage of t.Parallel()
- unconvert # Unnecessary type conversions
- unparam # Report unused function parameters
- usestdlibvars # Detect possibility to use variables/constants from stdlib
- wastedassign # Find wasted assignment statements
- whitespace # Detect leading/trailing whitespace
- wrapcheck # Check errors from external packages are wrapped
disable:
- cyclop # Too strict cyclomatic complexity
- depguard # Not needed for this project
- dogsled # Blank identifiers sometimes necessary
- err113 # Too strict for this project
- exhaustruct # Too strict for this project
- forcetypeassert # Sometimes type assertions are safe
- funlen # Function length checks too opinionated
- gochecknoglobals # Globals sometimes necessary
- gocognit # Cognitive complexity too opinionated
- godox # Allow TODO/FIXME comments
- grouper # Import grouping is handled by goimports
- importas # Not needed for this project
- inamedparam # Named parameters are fine
- interfacebloat # Interface size not a concern
- ireturn # Returning interfaces is acceptable
- maintidx # Maintainability index too opinionated
- mnd # Magic number detection too opinionated (replaces gomnd)
- nestif # Nesting depth checks too opinionated
- nlreturn # Blank line requirements too strict
- paralleltest # Not all tests should be parallel
- prealloc # Premature optimization
- tagalign # Tag alignment not critical
- tagliatelle # Tag naming not critical
- testifylint # Some patterns are acceptable
- varnamelen # Variable name length too opinionated
- wsl # Whitespace rules too strict
- zerologlint # Project uses slog not zerolog
settings:
errcheck:
check-type-assertions: true
check-blank: true
exclude-functions:
- (io.Closer).Close
- (*os.File).Close
govet:
enable-all: true
disable:
- fieldalignment # Struct field alignment not critical
- shadow # Shadow checking too strict
gocyclo:
min-complexity: 15
dupl:
threshold: 100
goconst:
min-len: 3
min-occurrences: 3
lll:
line-length: 120
tab-width: 1
misspell:
locale: US
nakedret:
max-func-lines: 30
gosec:
severity: medium
confidence: medium
excludes:
- G104 # Errors unhandled (covered by errcheck)
config:
G306: "0644" # Expect FileMode 0644 for config files
revive:
rules:
- name: exported
disabled: false
- name: package-comments
disabled: false
- name: var-naming
disabled: false
gocritic:
enabled-tags:
- diagnostic
- style
- performance
- experimental
- opinionated
disabled-checks:
- whyNoLint # Allow missing explanations for nolint directives
exclusions:
paths:
- node_modules
rules:
# Exclude some linters from running on tests files
- path: '_test\.go'
linters:
- dupl
- gosec
- goconst
- mnd
# Allow white-box testing in internal test files
- path: '_internal_test\.go'
linters:
- testpackage
# Exclude magic numbers in main.go (ports, timeouts, etc.)
- path: 'main\.go'
linters:
- mnd
# Allow globals in options package
- path: "internal/options/"
linters:
- gochecknoglobals
formatters:
enable:
- gofmt
- gofumpt
- goimports
- gci
settings:
gofumpt:
extra-rules: true
gci:
sections:
- standard
- default
- prefix(github.com/netresearch/ldap-selfservice-password-changer)
issues:
max-issues-per-linter: 0
max-same-issues: 0
uniq-by-line: true