-
Notifications
You must be signed in to change notification settings - Fork 933
Expand file tree
/
Copy path.golangci.yml
More file actions
144 lines (144 loc) · 5.35 KB
/
Copy path.golangci.yml
File metadata and controls
144 lines (144 loc) · 5.35 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
version: "2"
linters:
default: none
enable:
- errcheck
- gocritic
# TODO(GODRIVER-3712): Enable gosec in golangci-lint version 2.8.0
#- gosec
- govet
- ineffassign
- makezero
- misspell
- nakedret
- paralleltest
- prealloc
- revive
- staticcheck
- unconvert
- unparam
- unused
settings:
errcheck:
exclude-functions:
- .errcheck-excludes
govet:
disable:
- cgocall
- composites
paralleltest:
# Ignore missing calls to `t.Parallel()` and only report incorrect uses of
# `t.Parallel()`.
ignore-missing: true
staticcheck:
checks:
- all
# Disable deprecation warnings for now.
- -SA1012
# Disable "do not pass a nil Context" to allow testing nil contexts in
# tests.
- -SA1019
exclusions:
generated: lax
rules:
# Ignore some linters for example code that is intentionally simplified.
- linters:
- errcheck
- revive
path: examples/
# Disable "unused" linter for code files that depend on the
# "mongocrypt.MongoCrypt" type because the linter build doesn't work
# correctly with CGO enabled. As a result, all calls to a
# "mongocrypt.MongoCrypt" API appear to always panic (see
# mongocrypt_not_enabled.go), leading to confusing messages about unused
# code.
- linters:
- unused
path: x/mongo/driver/crypt.go|mongo/(crypt_retrievers|mongocryptd).go
# Ignore "TLS MinVersion too low", "TLS InsecureSkipVerify set true", and
# "Use of weak random number generator (math/rand instead of crypto/rand)"
# in tests. Disable gosec entirely for test files to reduce noise.
- linters:
- gosec
path: _test\.go
# Ignore prealloc warnings for test files.
- linters:
- prealloc
path: _test\.go
# Ignore missing comments for exported variable/function/type for code in
# the "internal" and "benchmark" directories.
- path: (internal\/|benchmark\/)
text: exported (.+) should have comment( \(or a comment on this block\))? or be unexported
# Ignore missing package comments for directories that aren't frequently
# used by external users.
- path: (internal\/|benchmark\/|x\/|cmd\/|mongo\/integration\/)
text: should have a package comment
# Add all default excluded issues except issues related to exported
# types/functions not having comments; we want those warnings. The
# defaults are copied from the "--exclude-use-default" documentation on
# https://golangci-lint.run/usage/configuration/#command-line-options
#
## Defaults ##
#
# EXC0001 errcheck: Almost all programs ignore errors on these functions
# and in most cases it's ok
- path: (.+)\.go$
text: Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked
# EXC0003 golint: False positive when tests are defined in package 'test'
- path: (.+)\.go$
text: func name will be used as test\.Test.* by other packages, and that stutters; consider calling this
# EXC0004 govet: Common false positives
- path: (.+)\.go$
text: (possible misuse of unsafe.Pointer|should have signature)
# EXC0005 staticcheck: Developers tend to write in C-style with an explicit 'break' in a 'switch', so it's ok to ignore
- path: (.+)\.go$
text: ineffective break statement. Did you mean to break out of the outer loop
# EXC0006 gosec: Too many false-positives on 'unsafe' usage
- path: (.+)\.go$
text: Use of unsafe calls should be audited
# EXC0007 gosec: Too many false-positives for parametrized shell calls
- path: (.+)\.go$
text: Subprocess launch(ed with variable|ing should be audited)
# EXC0008 gosec: Duplicated errcheck checks
- path: (.+)\.go$
text: (G104|G307)
# EXC0009 gosec: Too many issues in popular repos
- path: (.+)\.go$
text: (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)'
- path: (.+)\.go$
text: Potential file inclusion via variable
## End Defaults ##
# Ignore capitalization warning for this weird field name.
- path: (.+)\.go$
text: "var-naming: struct field CqCssWxW should be CqCSSWxW"
# Ignore warnings for common "wiremessage.Read..." usage because the
# safest way to use that API is by assigning possibly unused returned byte
# buffers.
- path: (.+)\.go$
text: "SA4006: this value of `wm` is never used"
- path: (.+)\.go$
text: "SA4006: this value of `rem` is never used"
- path: (.+)\.go$
text: ineffectual assignment to wm
- path: (.+)\.go$
text: ineffectual assignment to rem
paths:
- (^|/)testdata($|/)
- (^|/)etc($|/)
# Disable all linters for copied third-party code.
- internal/rand
- internal/aws
- internal/assert
formatters:
enable:
- goimports
exclusions:
generated: lax
paths:
- (^|/)testdata($|/)
- (^|/)etc($|/)
- internal/rand
- internal/aws
- internal/assert