...
1# We may as well allow multiple golangci-lint invocations at once.
2run:
3 allow-parallel-runners: true
4 go: "1.21"
5
6# golangci-lint by default ignores some staticcheck and vet raised issues that
7# are actually important to catch. The following ensures that we do not ignore
8# those tools ever.
9issues:
10 exclude-use-default: false
11 max-same-issues: 0 # print all failures
12
13linters:
14 disable-all: true
15 enable:
16 # Enabled by default linters: we want all except errcheck
17 - gosimple
18 - govet
19 - ineffassign
20 - staticcheck
21 - typecheck
22 - unused
23 # Not enabled by default: we want a good chunk
24 - asciicheck
25 - bidichk
26 - bodyclose
27 - durationcheck
28 - exhaustive
29 - exportloopref
30 - gocritic
31 - gofmt
32 - gofumpt
33 - goimports
34 - goprintffuncname
35 - gosec
36 - misspell
37 - nilerr
38 - noctx
39 - nolintlint
40 - revive
41 - rowserrcheck
42 - sqlclosecheck
43 - tenv
44 - unconvert
45 - unparam
46 - wastedassign
47 - whitespace
48
49linters-settings:
50 # A default case ensures we have checked everything. We should not require
51 # every enum to be checked if we want to default.
52 exhaustive:
53 default-signifies-exhaustive: true
54
55 # If we want to opt out of a lint, we require an explanation.
56 nolintlint:
57 allow-leading-space: true
58 allow-unused: false
59 require-explanation: true
60 require-specific: true
61
62 # We do not want every usage of fmt.Errorf to use %w.
63 errorlint:
64 errorf: false
65
66 # If gofumpt is run outside of a module, it assumes Go 1.0 rather than the
67 # latest Go. We always want the latest formatting.
68 #
69 # https://github.com/mvdan/gofumpt/issues/137
70 gofumpt:
71 lang-version: "1.21"
72 extra-rules: true
73
74 gosec:
75 excludes:
76 - G104 # unhandled errors, we exclude for the same reason we do not use errcheck
77 - G404 # we want math/rand
78
79 # Gocritic is a meta linter that has very good lints, and most of the
80 # experimental ones are very good too. We opt into everything, which helps
81 # us when we upgrade golangci-lint, and we specifically opt out of a batch.
82 #
83 # You can see what the opt-outs would flag by deleting them.
84 gocritic:
85 enabled-tags:
86 - diagnostic
87 - experimental
88 - opinionated
89 - performance
90 - style
91 disabled-checks:
92 - appendAssign
93 - builtinShadow
94 - commentedOutCode
95 - emptyStringTest
96 - evalOrder
97 - ifElseChain
98 - importShadow
99 - ptrToRefParam
100 - sloppyReassign
101 - tooManyResultsChecker
102 - typeDefFirst
103 - unnamedResult
104 - unnecessaryBlock
105 settings:
106 hugeParam:
107 sizeThreshold: 256
108 rangeValCopy:
109 sizeThreshold: 256
110
111 # Revive is yet another metalinter with a bunch of useful lints. The below
112 # opts in to all of the ones we would like to use.
113 revive:
114 ignore-generated-header: true
115 severity: warning
116 confidence: 0.8
117 error-code: 0
118 warning-code: 0
119 rules:
120 - name: atomic
121 - name: blank-imports
122 - name: bool-literal-in-expr
123 - name: call-to-gc
124 - name: constant-logical-expr
125 - name: context-as-argument
126 - name: context-keys-type
127 - name: defer
128 - name: dot-imports
129 - name: duplicated-imports
130 - name: early-return
131 - name: empty-block
132 - name: empty-lines
133 - name: error-naming
134 - name: error-return
135 - name: error-strings
136 - name: errorf
137 - name: get-return
138 - name: identical-branches
139 - name: if-return
140 - name: increment-decrement
141 - name: indent-error-flow
142 - name: optimize-operands-order
143 - name: range
144 - name: range-val-in-closure
145 - name: receiver-naming
146 - name: string-of-int
147 - name: struct-tag
148 - name: superfluous-else
149 - name: time-equal
150 - name: time-naming
151 - name: var-declaration
152 - name: unconditional-recursion
153 - name: unexported-naming
154 - name: unexported-return
155 - name: unnecessary-stmt
156 - name: unreachable-code
157 - name: unused-parameter
158 - name: unused-receiver
159 - name: useless-break
160 - name: waitgroup-by-value
161
162 # We disable the nil ctx check, because we deliberately internally use nil
163 # contexts for beneficial reasons, and we disable the SSLv3 deprecation
164 # warning because this is solely for a debug log.
165 staticcheck:
166 go: "1.21"
167 checks: ["all", "-SA1012", "-SA1019"]
View as plain text