This repository has been archived by the owner on Jan 22, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.golangci.yml
251 lines (231 loc) · 9.79 KB
/
.golangci.yml
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
run:
# Timeout for analysis, e.g. 30s, 5m.
# Default: 1m
timeout: 3m
# All available linters https://golangci-lint.run/usage/linters/
# All possible options can be found here https://github.com/golangci/golangci-lint/blob/master/.golangci.reference.yml
linters-settings:
cyclop:
# The maximal code complexity to report.
# Default: 10
max-complexity: 15
# The maximal average package complexity.
# If it's higher than 0.0 (float) the check is enabled
# Default: 0.0
package-average: 10.0
dupl:
threshold: 100
errcheck:
# Report about not checking of errors in type assertions: `a := b.(MyStruct)`.
# Such cases aren't reported by default.
# Default: false
check-type-assertions: true
exhaustive:
# Program elements to check for exhaustiveness.
# Default: [ switch ]
check:
- switch
- map
funlen:
# Checks the number of lines in a function.
# If lower than 0, disable the check.
# Default: 60
lines: 100
# Checks the number of statements in a function.
# If lower than 0, disable the check.
# Default: 40
statements: 50
# Ignore comments when counting lines.
# Default false
ignore-comments: true
goconst:
min-len: 2
min-occurrences: 2
gocognit:
# Minimal code complexity to report.
# Default: 30 (but we recommend 10-20)
min-complexity: 20
gocritic:
# Settings passed to gocritic.
# The settings key is the name of a supported gocritic checker.
# The list of supported checkers can be find in https://go-critic.github.io/overview.
settings:
captLocal:
# Whether to restrict checker to params only.
# Default: true
paramsOnly: false
underef:
# Whether to skip (*x).method() calls where x is a pointer receiver.
# Default: true
skipRecvDeref: false
gocyclo:
min-complexity: 15
goimports:
local-prefixes: github.com/golangci/golangci-lint
govet:
# Enable all analyzers.
# Default: false
enable-all: true
# Disable analyzers by name.
# Run `go tool vet help` to see all analyzers.
# Default: []
disable:
- fieldalignment
# Settings per analyzer.
settings:
shadow:
# Whether to be strict about shadowing; can be noisy.
# Default: false
strict: true
inamedparam:
# Skips check for interface methods with only a single parameter.
# Default: false
skip-single-param: true
lll:
line-length: 140
misspell:
locale: US
ignore-words:
- konstellation
mnd:
# List of function patterns to exclude from analysis.
# Values always ignored: `time.Date`,
# `strconv.FormatInt`, `strconv.FormatUint`, `strconv.FormatFloat`,
# `strconv.ParseInt`, `strconv.ParseUint`, `strconv.ParseFloat`.
# Default: []
ignored-functions:
- args.Error
- flag.Arg
- flag.Duration.*
- flag.Float.*
- flag.Int.*
- flag.Uint.*
- os.Chmod
- os.Mkdir.*
- os.OpenFile
- os.WriteFile
nolintlint:
# Exclude following linters from requiring an explanation.
# Default: []
allow-no-explanation: [funlen, gocognit, lll]
# Enable to require an explanation of nonzero length after each nolint directive.
# Default: false
require-explanation: true
# Enable to require nolint directives to mention the specific linter being suppressed.
# Default: false
require-specific: true
perfsprint:
# Optimizes into strings concatenation.
# Default: true
strconcat: false
reassign:
# Patterns for global variable names that are checked for reassignment.
# See https://github.com/curioswitch/go-reassign#usage
# Default: ["EOF", "Err.*"]
patterns:
- '.*'
sloglint:
# Enforce not using global loggers.
# Values:
# - "": disabled
# - "all": report all global loggers
# - "default": report only the default slog logger
# https://github.com/go-simpler/sloglint?tab=readme-ov-file#no-global
# Default: ""
no-global: 'all'
# Enforce using methods that accept a context.
# Values:
# - "": disabled
# - "all": report all contextless calls
# - "scope": report only if a context exists in the scope of the outermost function
# https://github.com/go-simpler/sloglint?tab=readme-ov-file#context-only
# Default: ""
context: 'scope'
linters:
# please, do not use `enable-all`: it's deprecated and will be removed soon.
disable-all: true
enable:
- asciicheck # checks that your code does not contain non-ASCII identifiers
- bodyclose # checks that HTTP response body is closed
- copyloopvar # detects places where loop variables are copied https://github.com/karamaru-alpha/copyloopvar
- dogsled # finds assignments/declarations with too many blank identifiers
- dupl # checks for duplicated code
- durationcheck # check for two durations multiplied together
- err113 # checks the errors handling expressions
- errcheck # ENABLED by default checks for unchecked errors in Go code.
- errorlint # finds code that will cause problems with the error wrapping scheme introduced in Go 1.13 (case, == and using %v instead of %w)
- exhaustive # checks exhaustiveness of enum switch statements
- funlen # detects long functions
- gochecknoglobals # checks that no global variables exist
- gochecknoinits # checks that no init functions are present in Go code
- gocognit # calculates the cognitive complexity of functions
- goconst # finds repeated strings that could be replaced by a constant
- gocritic # provides diagnostics that check for bugs, performance and style issues
- gocyclo # calculates cyclomatic complexities of functions
- godot # checks if comments end in a period
- godox # finds FIXME, TODO, etc. comments
- gofmt # checks whether code was gofmt-ed
- goimports # check import statements are formatted according to the 'goimport' command
- goprintffuncname # checks that printf-like functions are named with f at the end
- gosec # inspects source code for security problems
- gosimple # ENABLED by default linter for Go source code that specializes in simplifying code
- govet # ENABLED by default examines Go source code and reports suspicious constructs
# unsupported by gitlab ci 26/11/24 - iface # detect the incorrect use of interfaces https://github.com/uudashr/iface
- ineffassign # ENABLED by default detects when assignments to existing variables are not used
- inamedparam # checks for interface methods with only a single parameter
- lll # checks line length
- misspell # finds misspelled words
- nestif # checks for deeply nested if statements
- noctx # finds sending http.Request without context.Context
- nolintlint # reports ill-formed, insufficiently specific, or unused nolint directives
- perfsprint # optimizes string concatenation
- prealloc # finds slice declarations that could potentially be preallocated
- protogetter # reports direct reads from proto message fields when getters should be used
- reassign # checks that package variables are not reassigned
- revive # add extra rules to golint: https://github.com/mgechev/revive?tab=readme-ov-file#golangci-lint
- sloglint # checks for global loggers and contextless slog calls
- staticcheck # ENABLED by default using static analysis, it finds bugs and performance issues, offers simplifications, and enforces style rules
- stylecheck # add extra golint style checks: https://pkg.go.dev/honnef.co/go/tools/stylecheck
- testifylint # checks for common mistakes when using the testify package
- testpackage # checks that test files are in a separate _test package
- tparallel # detects inappropriate usage of t.Parallel() method in your Go test codes
- unconvert # remove unnecessary type conversions
- unparam # finds unused function parameters
- unused # ENABLED by default checks Go code for unused constants, variables, functions and types
- usestdlibvars # checks if the standard library variables can be used
- whitespace # checks for unnecessary newlines at the start and end of functions, if, for, etc
- wsl # add or remove empty lines
issues:
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
- path: _test\.go
linters:
- mnd
- gochecknoglobals
# https://github.com/go-critic/go-critic/issues/926
- linters:
- gocritic
text: 'unnecessaryDefer:'
- text: 'shadow: declaration of "(err|ctx)" shadows declaration at'
linters: [govet]
# Disable default exclude rules
exclude-use-default: false
exclude:
# EXC0001 errcheck: Almost all programs ignore errors on these functions and in most cases it's ok
- Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked
# EXC0004 govet: Common false positives
- (possible misuse of unsafe.Pointer|should have signature)
# EXC0006 gosec: Too many false-positives on 'unsafe' usage
- Use of unsafe calls should be audited
# EXC0007 gosec: Too many false-positives for parametrized shell calls
- Subprocess launch(ed with variable|ing should be audited)
# EXC0008 gosec: Duplicated errcheck checks
- (G104|G307)
# EXC0009 gosec: Too many issues in popular repos
- (Expect directory permissions to be 0750 or less|Expect file permissions to be 0600 or less)
# EXC0010 gosec: False positive is triggered by 'src, err := ioutil.ReadFile(filename)'
- Potential file inclusion via variable
# EXC0011 stylecheck: Annoying issue about not having a comment. The rare codebase has such comments
- (comment on exported (method|function|type|const)|should have( a package)? comment|comment should be of the form)
exclude-dirs:
- scripts