forked from connectrpc/connect-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.golangci.yml
134 lines (133 loc) · 5.23 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
run:
skip-dirs-use-default: false
linters-settings:
errcheck:
check-type-assertions: true
exhaustruct:
include:
# No zero values for param structs.
- 'connectrpc\.com/connect\..*[pP]arams'
forbidigo:
forbid:
- '^fmt\.Print'
- '^log\.'
- '^print$'
- '^println$'
- '^panic$'
godox:
# TODO, OPT, etc. comments are fine to commit. Use FIXME comments for
# temporary hacks, and use godox to prevent committing them.
keywords: [FIXME]
importas:
no-unaliased: true
alias:
- pkg: connectrpc.com/connect
alias: connect
- pkg: connectrpc.com/connect/internal/gen/connect/ping/v1
alias: pingv1
varnamelen:
ignore-decls:
- T any
- i int
- wg sync.WaitGroup
linters:
enable-all: true
disable:
- cyclop # covered by gocyclo
- deadcode # abandoned
- depguard # unnecessary for small libraries
- exhaustivestruct # replaced by exhaustruct
- funlen # rely on code review to limit function length
- gocognit # dubious "cognitive overhead" quantification
- gofumpt # prefer standard gofmt
- goimports # rely on gci instead
- golint # deprecated by Go team
- gomnd # some unnamed constants are okay
- ifshort # deprecated by author
- inamedparam # convention is not followed
- interfacer # deprecated by author
- ireturn # "accept interfaces, return structs" isn't ironclad
- lll # don't want hard limits for line length
- maintidx # covered by gocyclo
- maligned # readability trumps efficient struct packing
- nlreturn # generous whitespace violates house style
- nonamedreturns # named returns are fine; it's *bare* returns that are bad
- nosnakecase # deprecated in https://github.com/golangci/golangci-lint/pull/3065
- protogetter # too many false positives
- scopelint # deprecated by author
- structcheck # abandoned
- testpackage # internal tests are fine
- varcheck # abandoned
- wrapcheck # don't _always_ need to wrap errors
- wsl # generous whitespace violates house style
issues:
exclude:
# Don't ban use of fmt.Errorf to create new errors, but the remaining
# checks from err113 are useful.
- "err113: do not define dynamic errors.*"
exclude-rules:
# If future reflect.Kinds are nil-able, we'll find out when a test fails.
- linters: [exhaustive]
path: internal/assert/assert.go
# We need our duplex HTTP call to have access to the context.
- linters: [containedctx]
path: duplex_http_call.go
# We need to init a global in-mem HTTP server for testable examples.
- linters: [gochecknoinits, gochecknoglobals]
path: example_init_test.go
# We need to initialize default grpc User-Agent
- linters: [gochecknoglobals]
path: protocol_grpc.go
# We need to initialize default connect User-Agent
- linters: [gochecknoglobals]
path: protocol_connect.go
# We purposefully do an ineffectual assignment for an example.
- linters: [ineffassign]
path: client_example_test.go
# The generated file is effectively a global receiver.
- linters: [varnamelen]
path: cmd/protoc-gen-connect-go
text: "parameter name 'g' is too short"
# Thorough error logging and timeout config make this example unreadably long.
- linters: [errcheck, gosec]
path: error_writer_example_test.go
# It should be crystal clear that Connect uses plain *http.Clients.
- linters: [revive, stylecheck]
path: client_example_test.go
# Don't complain about timeout management or lack of output assertions in examples.
- linters: [gosec, testableexamples]
path: handler_example_test.go
# No output assertions needed for these examples.
- linters: [testableexamples]
path: error_writer_example_test.go
- linters: [testableexamples]
path: error_not_modified_example_test.go
- linters: [testableexamples]
path: error_example_test.go
# In examples, it's okay to use http.ListenAndServe.
- linters: [gosec]
path: error_not_modified_example_test.go
# There are many instances where we want to keep unused parameters
# as a matter of style or convention, for example when a context.Context
# is the first parameter, we choose to just globally ignore this.
- linters: [revive]
text: "^unused-parameter: "
# We want to return explicit nils in protocol_grpc.go
- linters: [revive]
text: "^if-return: "
path: protocol_grpc.go
# We want to return explicit nils in protocol_connect.go
- linters: [revive]
text: "^if-return: "
path: protocol_connect.go
# We want to return explicit nils in error_writer.go
- linters: [revive]
text: "^if-return: "
path: error_writer.go
# We want to set http.Server's logger
- linters: [forbidigo]
path: internal/memhttp
text: "use of `log.(New|Logger|Lshortfile)` forbidden by pattern .*"
# We want to show examples with http.Get
- linters: [noctx]
path: internal/memhttp/memhttp_test.go