Skip to content

Commit f9579b5

Browse files
committed
Migrate golangci-lint configuration file.
1 parent b58aeae commit f9579b5

File tree

1 file changed

+81
-97
lines changed

1 file changed

+81
-97
lines changed

.golangci.yml

Lines changed: 81 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
run:
2-
timeout: 5m
3-
1+
version: "2"
42
linters:
5-
disable-all: true
3+
default: none
64
# TODO(GODRIVER-2156): Enable all commented-out linters.
75
enable:
86
- errcheck
97
# - errorlint
10-
- exportloopref
118
- gocritic
12-
- goimports
13-
- gosimple
149
- gosec
1510
- govet
1611
- ineffassign
@@ -21,95 +16,84 @@ linters:
2116
- prealloc
2217
- revive
2318
- staticcheck
24-
- typecheck
25-
- unused
2619
- unconvert
2720
- unparam
28-
29-
linters-settings:
30-
errcheck:
31-
exclude-functions: .errcheck-excludes
32-
govet:
33-
disable:
34-
- cgocall
35-
- composites
36-
paralleltest:
37-
# Ignore missing calls to `t.Parallel()` and only report incorrect uses of `t.Parallel()`.
38-
ignore-missing: true
39-
staticcheck:
40-
checks: [
41-
"all",
42-
"-SA1019", # Disable deprecation warnings for now.
43-
"-SA1012", # Disable "do not pass a nil Context" to allow testing nil contexts in tests.
44-
]
45-
46-
issues:
47-
exclude-dirs-use-default: false
48-
exclude-dirs:
49-
- (^|/)testdata($|/)
50-
- (^|/)etc($|/)
51-
# Disable all linters for copied third-party code.
52-
- internal/rand
53-
- internal/aws
54-
- internal/assert
55-
exclude-use-default: false
56-
exclude:
57-
# Add all default excluded issues except issues related to exported types/functions not having
58-
# comments; we want those warnings. The defaults are copied from the "--exclude-use-default"
59-
# documentation on https://golangci-lint.run/usage/configuration/#command-line-options
60-
## Defaults ##
61-
# EXC0001 errcheck: Almost all programs ignore errors on these functions and in most cases it's ok
62-
- Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked
63-
# EXC0003 golint: False positive when tests are defined in package 'test'
64-
- func name will be used as test\.Test.* by other packages, and that stutters; consider calling this
65-
# EXC0004 govet: Common false positives
66-
- (possible misuse of unsafe.Pointer|should have signature)
67-
# EXC0005 staticcheck: Developers tend to write in C-style with an explicit 'break' in a 'switch', so it's ok to ignore
68-
- ineffective break statement. Did you mean to break out of the outer loop
69-
# EXC0006 gosec: Too many false-positives on 'unsafe' usage
70-
- Use of unsafe calls should be audited
71-
# EXC0007 gosec: Too many false-positives for parametrized shell calls
72-
- Subprocess launch(ed with variable|ing should be audited)
73-
# EXC0008 gosec: Duplicated errcheck checks
74-
- (G104|G307)
75-
# EXC0009 gosec: Too many issues in popular repos
76-
- (Expect directory permissions to be 0750 or less|Expect file permissions to be 0600 or less)
77-
# EXC0010 gosec: False positive is triggered by 'src, err := ioutil.ReadFile(filename)'
78-
- Potential file inclusion via variable
79-
## End Defaults ##
80-
81-
# Ignore capitalization warning for this weird field name.
82-
- "var-naming: struct field CqCssWxW should be CqCSSWxW"
83-
# Ignore warnings for common "wiremessage.Read..." usage because the safest way to use that API
84-
# is by assigning possibly unused returned byte buffers.
85-
- "SA4006: this value of `wm` is never used"
86-
- "SA4006: this value of `rem` is never used"
87-
- "ineffectual assignment to wm"
88-
- "ineffectual assignment to rem"
89-
90-
exclude-rules:
91-
# Ignore some linters for example code that is intentionally simplified.
92-
- path: examples/
93-
linters:
94-
- revive
95-
- errcheck
96-
# Disable "unused" linter for code files that depend on the "mongocrypt.MongoCrypt" type because
97-
# the linter build doesn't work correctly with CGO enabled. As a result, all calls to a
98-
# "mongocrypt.MongoCrypt" API appear to always panic (see mongocrypt_not_enabled.go), leading
99-
# to confusing messages about unused code.
100-
- path: x/mongo/driver/crypt.go|mongo/(crypt_retrievers|mongocryptd).go
101-
linters:
102-
- unused
103-
# Ignore "TLS MinVersion too low", "TLS InsecureSkipVerify set true", and "Use of weak random
104-
# number generator (math/rand instead of crypto/rand)" in tests.
105-
- path: _test\.go
106-
text: G401|G402|G404
107-
linters:
108-
- gosec
109-
# Ignore missing comments for exported variable/function/type for code in the "internal" and
110-
# "benchmark" directories.
111-
- path: (internal\/|benchmark\/)
112-
text: exported (.+) should have comment( \(or a comment on this block\))? or be unexported
113-
# Ignore missing package comments for directories that aren't frequently used by external users.
114-
- path: (internal\/|benchmark\/|x\/|cmd\/|mongo\/integration\/)
115-
text: should have a package comment
21+
- unused
22+
settings:
23+
errcheck:
24+
exclude-functions:
25+
- .errcheck-excludes
26+
govet:
27+
disable:
28+
- cgocall
29+
- composites
30+
paralleltest:
31+
ignore-missing: true
32+
staticcheck:
33+
checks:
34+
- all
35+
- -SA1012
36+
- -SA1019
37+
exclusions:
38+
generated: lax
39+
rules:
40+
- linters:
41+
- errcheck
42+
- revive
43+
path: examples/
44+
- linters:
45+
- unused
46+
path: x/mongo/driver/crypt.go|mongo/(crypt_retrievers|mongocryptd).go
47+
- linters:
48+
- gosec
49+
path: _test\.go
50+
text: G401|G402|G404
51+
- path: (internal\/|benchmark\/)
52+
text: exported (.+) should have comment( \(or a comment on this block\))? or be unexported
53+
- path: (internal\/|benchmark\/|x\/|cmd\/|mongo\/integration\/)
54+
text: should have a package comment
55+
- path: (.+)\.go$
56+
text: Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked
57+
- path: (.+)\.go$
58+
text: func name will be used as test\.Test.* by other packages, and that stutters; consider calling this
59+
- path: (.+)\.go$
60+
text: (possible misuse of unsafe.Pointer|should have signature)
61+
- path: (.+)\.go$
62+
text: ineffective break statement. Did you mean to break out of the outer loop
63+
- path: (.+)\.go$
64+
text: Use of unsafe calls should be audited
65+
- path: (.+)\.go$
66+
text: Subprocess launch(ed with variable|ing should be audited)
67+
- path: (.+)\.go$
68+
text: (G104|G307)
69+
- path: (.+)\.go$
70+
text: (Expect directory permissions to be 0750 or less|Expect file permissions to be 0600 or less)
71+
- path: (.+)\.go$
72+
text: Potential file inclusion via variable
73+
- path: (.+)\.go$
74+
text: 'var-naming: struct field CqCssWxW should be CqCSSWxW'
75+
- path: (.+)\.go$
76+
text: 'SA4006: this value of `wm` is never used'
77+
- path: (.+)\.go$
78+
text: 'SA4006: this value of `rem` is never used'
79+
- path: (.+)\.go$
80+
text: ineffectual assignment to wm
81+
- path: (.+)\.go$
82+
text: ineffectual assignment to rem
83+
paths:
84+
- (^|/)testdata($|/)
85+
- (^|/)etc($|/)
86+
- internal/rand
87+
- internal/aws
88+
- internal/assert
89+
formatters:
90+
enable:
91+
- goimports
92+
exclusions:
93+
generated: lax
94+
paths:
95+
- (^|/)testdata($|/)
96+
- (^|/)etc($|/)
97+
- internal/rand
98+
- internal/aws
99+
- internal/assert

0 commit comments

Comments
 (0)