-
Notifications
You must be signed in to change notification settings - Fork 1
/
.golangci.yml
202 lines (193 loc) · 8.92 KB
/
.golangci.yml
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
run:
deadline: 10m
issues-exit-code: 1
tests: true
linters:
enable:
- bidichk # find dangerous bidi unicode symbols
- bodyclose # find unclosed http response bodies
- dogsled # checks for too many ignored arguments
- durationcheck # verifies whether durations are multiplied, usually a mistake
- errcheck # find unchecked errors
- errorlint # finds misuses of errors
- exportloopref # check for exported loop vars
- gocritic # checks for style, performance issues, and common programming errors
- godot # dots for everything
- err113 # check error expressions
- gofmt # sanity check formatting
- goprintffuncname # checks that printf-like functions are named with `f` at the end [fast: true, auto-fix: false]
- govet # check standard vet rules
- importas # verify that imports are consistent
- ineffassign # find ineffective assignments
- makezero # verifies that slices use defaults
- misspell # check spelling
- nakedret # check for naked returns
- nilerr # checks for misuses of `if err != nil { return nil }`
- noctx # finds locations that should use context
- revive # check standard linting rules
- tenv # ensure we use t.SetEnv instead of os.SetEnv
- unconvert # remove unnecessary conversions
- wastedassign
#TODO#- nilnil # needs fixes; checks that we don't return a nil and no-error
#TODO#- forcetypeassert # needs work to replace unchecked interface type assertion
#TODO#- gochecknoglobals # needs work to remove globals
#TODO#- gochecknoinits # needs work to remove init()
#TODO#- gofumpt # not sure whether it's useful
#TODO#- nestif # looks useful, however needs work
#TODO#- prealloc # easy optimizations
#TODO#- unparam # check for unused parameters
#TODO#- whitespace # checks for leading/trailing newlines
disable:
- nolintlint # checks that nolint directives are correct
- staticcheck # we already use staticcheck separately
- asciicheck # non-ascii is allowed
- containedctx # gives false positives, however might be good to re-evaluate
- contextcheck # doesn't look like it's useful
- cyclop # this complexity is not a good metric
- decorder # not that useful
- depguard # unused
- dupl # slow
- errchkjson # false positives, checks for non-encodable json types
- errname # we have different approach
- exhaustive # doesn't handle default case
- forbidigo # not useful
- funlen # no limit on func length
- gci # we have custom import checking
- gocognit # this complexity is not a good metric
- goconst # check for things that could be replaced by constants
- gocyclo # this complexity is not a good metric
- godox # too many false positivies
- goheader # separate tool
- goimports # disabled, because it's slow, using scripts/check-imports.go instead.
- gomnd # false positives
- gomoddirectives # not useful
- gomodguard # not useful
- gosec # needs tweaking
- gosimple # part of staticcheck
- grouper # we have a custom implementation
- ireturn # not that useful for us
- lll # don't need this check
- maintidx # code complexity based on halsted V and cyclomatic, both shown to be ineffective
- nlreturn # non-important code style
- paralleltest # too many false positives
- predeclared # kind of useful, but not critical
- promlinter # not relevant
- rowserrcheck # checks if sql.Rows.Err is checked correctly - Disabled because it reports false positive with defer statements after Query call
- sqlclosecheck # we have tagsql, which checks this better
- stylecheck # has false positives
- tagliatelle # not our style
- testpackage # sometimes it's useful to have tests on private funcs
- thelper # too many false positives
- tparallel # false positivies
- unused # part of staticcheck
- varnamelen # unenecssary
- wrapcheck # too much noise and false positives
- wsl # too much noise
fast: false
output:
formats:
- format: colored-line-number
print-issued-lines: true
print-linter-name: true
linters-settings:
errcheck:
# report about not checking of errors in type assetions: `a := b.(MyStruct)`;
# default is false: such cases aren't reported by default.
check-type-assertions: false
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
# default is false: such cases aren't reported by default.
check-blank: false
govet:
# report about shadowed variables
#TODO# check-shadowing: true
# Obtain type information from installed (to $GOPATH/pkg) package files:
# golangci-lint will execute `go install -i` and `go test -i` for analyzed packages
# before analyzing them.
# Enable this option only if all conditions are met:
# 1. you use only "fast" linters (--fast e.g.): no program loading occurs
# 2. you use go >= 1.10
# 3. you do repeated runs (false for CI) or cache $GOPATH/pkg or `go env GOCACHE` dir in CI.
use-installed-packages: false
gocritic:
disabled-checks:
- ifElseChain
goimports:
local: "storj.io"
golint:
min-confidence: 0.8
gofmt:
simplify: true
gocyclo:
min-complexity: 10
dupl:
threshold: 150
goconst:
min-len: 3
min-occurrences: 3
misspell:
lll:
line-length: 140
tab-width: 1
unused:
# treat code as a program (not a library) and report unused exported identifiers; default is false.
# XXX: if you enable this setting, unused will report a lot of false-positives in text editors:
# if it's called for subdir of a project it can't find funcs usages. All text editor integrations
# with golangci-lint call it on a directory with the changed file.
check-exported: false
unparam:
# call graph construction algorithm (cha, rta). In general, use cha for libraries,
# and rta for programs with main packages. Default is cha.
algo: cha
# Inspect exported functions, default is false. Set to true if no external program/library imports your code.
# XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
# if it's called for subdir of a project it can't find external interfaces. All text editor integrations
# with golangci-lint call it on a directory with the changed file.
check-exported: false
nakedret:
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
max-func-lines: 30
prealloc:
# Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
# True by default.
simple: true
range-loops: true # Report preallocation suggestions on range loops, true by default
for-loops: false # Report preallocation suggestions on for loops, false by default
issues:
max-issues-per-linter: 0
max-same-issues: 0
new: false
exclude-use-default: false
exclude-files:
- ".*\\.pb\\.go$"
- ".*\\.dbx\\.go$"
exclude-rules:
- linters:
- err113
text: "do not define dynamic errors"
- linters: # uninteresting, it would be nice to be consistent, but we don't want to block the build for it
- revive
text: "if-return"
- linters: # a lot of false-positives for c exports
- revive
text: "var-naming"
- linters: # uninteresting, error doesn't need to be the last type
- revive
text: "error-return"
- linters: # uninteresting, ideally we would have this on, but we need to fix all the packages first
- revive
text: "package-comments"
- linters: # uninteresting, it would be nice to be consistent, but we don't want to block the build for it
- revive
text: "superfluous-else"
- linters: # uninteresting, it would be nice to be consistent, but we don't want to block the build for it
- revive
text: "indent-error-flow"
- linters: # uninteresting, it's common to leave args unused
- revive
text: "unused-parameter"
- linters: # false positives, see https://github.com/mgechev/revive/issues/810
- revive
text: "empty-block"
- linters: # uninteresting, it's fine to redefine builtins
- revive
text: "redefines-builtin-id"