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