-
Notifications
You must be signed in to change notification settings - Fork 128
/
.golangci.yml
157 lines (139 loc) · 4.89 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
---
linters-settings:
exhaustive:
default-signifies-exhaustive: true
cyclop:
max-complexity: 30
depguard:
rules:
main:
deny:
- pkg: "errors"
desc: use "github.com/pkg/errors" instead
- pkg: "github.com/gogo/protobuf/proto"
desc: use "github.com/golang/protobuf/proto" instead
- pkg: "github.com/percona/go-mysql/log/slow"
desc: only use the forked parser
- pkg: "github.com/percona-platform/platform"
desc: use "github.com/percona-platform/saas" instead
- pkg: "gopkg.in/yaml.v2"
desc: use "gopkg.in/yaml.v3" instead
gci:
sections:
- standard # Captures all standard packages if they do not match another section.
- default # Contains all imports that could not be matched to another section type.
- prefix(github.com/percona/pmm) # Groups all local imports.
godot:
capital: true
period: true
scope: toplevel
exclude:
- go-sumtype:decl
- pmm-managed
goimports:
local-prefixes: github.com/percona/pmm
gomoddirectives:
replace-allow-list:
- github.com/percona-platform/dbaas-api
ireturn:
allow:
- anon
- error
- empty
- stdlib
- github.com/charmbracelet/bubbletea.Model
- github.com/percona/pmm/admin/commands.Result
- github.com/percona/pmm/agent/runner/actions.Action
- github.com/percona/pmm/managed/services/telemetry.DataSource
lll:
line-length: 170
tab-width: 4
maintidx:
under: 20
nestif:
min-complexity: 7
tagliatelle:
# Check the struck tag name case.
case:
rules:
avro: snake
bson: camel
# Disabled because we have too many errors at the moment
json: ""
# Disabled because we have too many errors at the moment
yaml: ""
xml: camel
unused:
check-exported: false #TODO: set true for agent
unparam:
check-exported: true
linters:
enable-all: true
disable:
# keep the rules sorted alpahbetically
- execinquery # false positives only
- exhaustivestruct # too annoying
- exhaustruct # too many files to fix/nolint
- deadcode # unmaintained, we leverage `unused`
- dupl # we can't avoid duplicating code
- funlen # useless
- gochecknoglobals # mostly useless
- gochecknoinits # we use init functions
- gocyclo # using cyclop with the max 30 instead
- godox # we sometimes leave TODOS right in the code
- goerr113 # extra work & poor benefit
- golint # unmaintained, replaced by revive
- gomnd # we are using numbers in many cases
- gomoddirectives # we use replace directives
- ifshort # a lot of false positives
- interfacer # deprecated
- maligned # deprecated
- nlreturn # too annoying
- nosnakecase # deprecated
- rowserrcheck # disabled because of generics
- scopelint # too many false positives
- structcheck # replaced by unused
- varcheck # replaced by unused
- varnamelen # useless
- wastedassign # disabled because of generics
- wrapcheck # we do not use wrapping everywhere
- wsl # too annoying
# TODO: carefully review all the rules below and either fix the code
# or leave disabled and provide a reason why
#- tagliatelle
#- revive
- paralleltest
- gocognit
- tagalign
# ENDTODO
run:
timeout: 5m
skip-dirs:
- agent/agents/mongodb/internal/
- qan-api2/migrations/
issues:
exclude-use-default: false
exclude:
# gas: Duplicated errcheck checks
- "G104: Errors unhandled"
# golint: Methods for implementing interfaces are not documented
- "exported method `.+` should have comment or be unexported"
- "comment on exported method `.+` should be of the form `.+ ...`"
# golint: We have to return unexported types due to oneof implementation
- "exported method .+ returns unexported type .+, which can be annoying to use"
exclude-rules:
- path: _test\.go
linters:
# keep sorted
- contextcheck # not critical, too many things to disable
- exhaustivestruct # very annoying
- forcetypeassert # for tests' brevity sake
- funlen # tests may be long
- gocognit # triggered by subtests
- gomnd # tests are full of magic numbers
- ireturn # we have exceptions, so need to silence them in tests
- lll # tests often require long lines
- maintidx # not critical for tests
- nonamedreturns # not critical for tests, albeit desirable
- testpackage # senseless
- unused # very annoying false positive: https://github.com/golangci/golangci-lint/issues/791