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
|
# options for analysis running
run:
# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 10m
modules-download-mode: readonly
# list of useful linters could be found at https://github.com/golangci/awesome-go-linters
linters:
disable-all: true
enable:
- bidichk
- depguard
- errcheck
- errname
- exportloopref
- forbidigo
- gci
- gitaly-linters
# We use both gofmt and gofumpt because gofumpt doesn't seem to be linting
# for simplifications, while gofmt does.
- gofmt
- gofumpt
- goimports
- gosimple
- govet
- ineffassign
- makezero
- megacheck
- misspell
- noctx
- nolintlint
- paralleltest
- revive
- rowserrcheck
- staticcheck
- stylecheck
- sqlclosecheck
- tenv
- thelper
- unconvert
- unused
- wastedassign
linters-settings:
depguard:
rules:
main:
deny:
- pkg: "io/ioutil"
desc: "ioutil is deprecated starting with Go 1.16"
- pkg: "gitlab.com/gitlab-org/labkit/log"
desc: "use internal/log instead"
errcheck:
# The following are functions for which we are currently not consistently
# checking returned errors. This is not intended as a list of known-okay
# cases to skip the checks, but rather as a list of things we should
# eventually fix.
exclude-functions:
- (*database/sql.DB).Close
- (*database/sql.Rows).Close
- (*gitlab.com/gitlab-org/gitaly/v16/client.Pool).Close
- (*gitlab.com/gitlab-org/gitaly/v16/internal/grpc/sidechannel.ServerConn).Close
- (*gitlab.com/gitlab-org/gitaly/v16/internal/streamcache.pipe).Close
- (*gitlab.com/gitlab-org/gitaly/v16/internal/streamcache.pipeReader).Close
- (*google.golang.org/grpc.ClientConn).Close
- (*google.golang.org/grpc.ServerConn).Close
- (*io.PipeReader).Close
- (*io.PipeWriter).Close
- (*os.File).Close
- (io.Closer).Close
- (net.Conn).Close
- (net.Listener).Close
forbidigo:
forbid:
- p: ^logrus\.(Debug|Error|Fatal|Info|Panic|Print|Trace|Warn|Warning)(f|ln)?$
msg: Use an injected logger or `ctxlogrus.Extract()`.
- p: ^logrus\.StandardLogger$
msg: Use an injected logger or `ctxlogrus.Extract()`.
- p: ^logrus\.New$
msg: Use an injected logger or `ctxlogrus.Extract()`.
- p: ^logrus\.With(Context|Error|Field|Fields|Time)$
msg: Use an injected logger or `ctxlogrus.Extract()`.
analyze-types: true
paralleltest:
# Ignore missing calls to `t.Parallel()` and only report incorrect uses of it.
ignore-missing: true
revive:
# Specifying any rule explicitly will disable the default-enabled rules.
# Manually specify the defaults along with `context-as-argument`.
rules:
- name: blank-imports
disabled: false
- name: context-as-argument
arguments:
# The context should always be first, except in our testing packages.
allowTypesBefore: "*testing.T,*testing.B,testing.TB"
- name: dot-imports
disabled: false
- name: error-naming
disabled: false
- name: error-return
disabled: false
- name: error-strings
disabled: false
- name: exported
disabled: false
- name: increment-decrement
disabled: false
- name: indent-error-flow
disabled: false
- name: receiver-naming
disabled: false
- name: range
disabled: false
- name: var-naming
disabled: false
stylecheck:
# ST1000 checks for missing package comments. We don't use these for most
# packages, so let's disable this check.
checks: [ "all", "-ST1000" ]
thelper:
test:
# The following linter would check whether we always call `t.Helper()` in
# functions that are not the top-level testcase. While this is nice in
# theory, in practice it would also impact e.g. usecases like
# `testhelper.NewFeatureSets(...).Run(t, testWithFeatures)`. This isn't
# really what we want, so we just leave these as disabled for the time
# being.
begin: false
benchmark:
begin: false
tb:
begin: false
custom:
gitaly-linters:
path: ./_build/tools/gitaly-linters.so
description: A collection of linters tailored for Gitaly
original-url: gitlab.com/gitlab-org/gitaly
settings:
string_interpolation_quote:
included-functions:
- fmt.*
error_wrap:
included-functions:
- fmt.Errorf
- gitlab.com/gitlab-org/gitaly/v16/internal/structerr.*
unavailable_code:
included-functions:
- gitlab.com/gitlab-org/gitaly/v16/internal/structerr.NewUnavailable
testhelper_run:
included-functions:
- gitlab.com/gitlab-org/gitaly/v16/internal/testhelper.Run
issues:
exclude-use-default: false
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
max-issues-per-linter: 0
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
max-same-issues: 0
|