11version : " 2"
22linters :
3+ # Keep this list sorted alphabetically
34 enable :
5+ - depguard
46 - errorlint
7+ - exptostd
8+ # - fatcontext
9+ # - gocritic
10+ # - godot
11+ - govet
12+ - loggercheck
513 - misspell
14+ - nilnesserr
15+ # TODO(bwplotka): Enable once https://github.com/golangci/golangci-lint/issues/3228 is fixed.
16+ # - nolintlint
617 - perfsprint
18+ - predeclared
719 - revive
20+ - sloglint
821 - testifylint
22+ # - unconvert
23+ - unused
24+ # - usestdlibvars
25+ - whitespace
26+ exclusions :
27+ generated : lax
28+ presets :
29+ - comments
30+ - common-false-positives
31+ - legacy
32+ - std-error-handling
33+ paths :
34+ - third_party$
35+ - builtin$
36+ - examples$
37+ rules :
38+ - linters :
39+ - errcheck
40+ # Taken from the default exclusions in v1.
41+ text : Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked
42+ - linters :
43+ - govet
44+ # We use many Seek methods that do not follow the usual pattern.
45+ text : " stdmethods: method Seek.* should have signature Seek"
46+ - linters :
47+ - revive
48+ # We have stopped at some point to write doc comments on exported symbols.
49+ # TODO(beorn7): Maybe we should enforce this again?
50+ text : exported (.+) should have comment( \(or a comment on this block\))? or be unexported
51+ - linters :
52+ - gocritic
53+ text : " appendAssign"
54+ - linters :
55+ - errcheck
56+ path : _test.go
57+ - linters :
58+ - errorlint
59+ path : " tsdb/head_wal.go"
60+ - linters :
61+ - godot
62+ source : " ^// ==="
63+ warn-unused : true
964 settings :
65+ depguard :
66+ rules :
67+ main :
68+ deny :
69+ # - pkg: "sync/atomic"
70+ # desc: "Use go.uber.org/atomic instead of sync/atomic"
71+ - pkg : " github.com/go-kit/kit/log"
72+ desc : " Use github.com/go-kit/log instead of github.com/go-kit/kit/log"
73+ - pkg : " io/ioutil"
74+ desc : " Use corresponding 'os' or 'io' functions instead."
75+ # - pkg: "regexp"
76+ # desc: "Use github.com/grafana/regexp instead of regexp"
77+ - pkg : " github.com/pkg/errors"
78+ desc : " Use 'errors' or 'fmt' instead of github.com/pkg/errors"
79+ - pkg : " gzip"
80+ desc : " Use github.com/klauspost/compress instead of gzip"
81+ - pkg : " zlib"
82+ desc : " Use github.com/klauspost/compress instead of zlib"
83+ - pkg : " golang.org/x/exp/slices"
84+ desc : " Use 'slices' instead."
85+ errcheck :
86+ exclude-functions :
87+ # Don't flag lines such as "io.Copy(io.Discard, resp.Body)".
88+ - io.Copy
89+ # The next two are used in HTTP handlers, any error is handled by the server itself.
90+ - io.WriteString
91+ - (net/http.ResponseWriter).Write
92+ # No need to check for errors on server's shutdown.
93+ - (*net/http.Server).Shutdown
94+ # Never check for rollback errors as Rollback() is called when a previous error was detected.
95+ - (github.com/prometheus/prometheus/storage.Appender).Rollback
96+ govet :
97+ disable :
98+ - shadow
99+ - fieldalignment
100+ enable-all : true
10101 perfsprint :
11102 # Optimizes even if it requires an int or uint type cast.
12103 int-conversion : true
@@ -19,36 +110,79 @@ linters:
19110 # Optimizes into strings concatenation.
20111 strconcat : false
21112 revive :
113+ # By default, revive will enable only the linting rules that are named in the configuration file.
114+ # So, it's needed to explicitly enable all required rules here.
22115 rules :
23- # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-parameter
116+ # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md
117+ - name : blank-imports
118+ - name : comment-spacings
119+ - name : context-as-argument
120+ arguments :
121+ # Allow functions with test or bench signatures.
122+ - allowTypesBefore : ' *testing.T,testing.TB'
123+ - name : context-keys-type
124+ # - name: dot-imports
125+ # - name: early-return
126+ # arguments:
127+ # - "preserveScope"
128+ # A lot of false positives: incorrectly identifies channel draining as "empty code block".
129+ # See https://github.com/mgechev/revive/issues/386
130+ - name : empty-block
131+ disabled : true
132+ - name : error-naming
133+ - name : error-return
134+ - name : error-strings
135+ - name : errorf
136+ # - name: exported
137+ # - name: increment-decrement
138+ # - name: indent-error-flow
139+ # arguments:
140+ # - "preserveScope"
141+ - name : package-comments
142+ # TODO(beorn7): Currently, we have a lot of missing package doc comments. Maybe we should have them.
143+ disabled : true
144+ - name : range
145+ # - name: receiver-naming
146+ - name : redefines-builtin-id
147+ - name : superfluous-else
148+ arguments :
149+ - " preserveScope"
150+ - name : time-naming
151+ # - name: unexported-return
152+ - name : unreachable-code
24153 - name : unused-parameter
25154 severity : warning
26155 disabled : true
156+ # - name: unused-receiver
157+ # - name: var-declaration
158+ # - name: var-naming
27159 testifylint :
28160 enable-all : true
29161 disable :
162+ - float-compare
30163 - go-require
31164 formatter :
32165 require-f-funcs : true
33- exclusions :
34- generated : lax
35- presets :
36- - comments
37- - common-false-positives
38- - legacy
39- - std-error-handling
40- paths :
41- - third_party$
42- - builtin$
43- - examples$
44166issues :
45167 max-issues-per-linter : 0
46168 max-same-issues : 0
169+ output :
170+ show-stats : false
171+ run :
172+ timeout : 15m
47173formatters :
48174 enable :
175+ - gci
49176 - gofumpt
50177 - goimports
51178 settings :
179+ gci :
180+ sections :
181+ - standard
182+ - default
183+ - prefix(github.com/prometheus/common)
184+ gofumpt :
185+ extra-rules : true
52186 goimports :
53187 local-prefixes :
54188 - github.com/prometheus/common
0 commit comments