|
1 |
| -# Copyright The containerd Authors. |
2 |
| - |
3 |
| -# Licensed under the Apache License, Version 2.0 (the "License"); |
4 |
| -# you may not use this file except in compliance with the License. |
5 |
| -# You may obtain a copy of the License at |
6 |
| - |
7 |
| -# http://www.apache.org/licenses/LICENSE-2.0 |
8 |
| - |
9 |
| -# Unless required by applicable law or agreed to in writing, software |
10 |
| -# distributed under the License is distributed on an "AS IS" BASIS, |
11 |
| -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 |
| -# See the License for the specific language governing permissions and |
13 |
| -# limitations under the License. |
14 |
| - |
15 |
| -# ----------------------------------------------------------------------------- |
16 |
| -# From https://github.com/containerd/nerdctl/blob/v0.12.1/.golangci.yml |
17 |
| -# ----------------------------------------------------------------------------- |
18 |
| ---- |
| 1 | +# golangci-lint configuration file. |
| 2 | +# https://golangci-lint.run/usage/configuration/ |
| 3 | +version: "2" |
19 | 4 | run:
|
20 | 5 | concurrency: 6
|
21 |
| - timeout: 2m # to avoid timeout locally |
22 | 6 | linters:
|
23 |
| - disable-all: true |
| 7 | + default: none |
24 | 8 | enable:
|
25 |
| - - depguard |
26 |
| - - gofmt |
27 |
| - - goimports |
28 |
| - - govet |
29 |
| - - ineffassign |
30 |
| - - misspell |
31 |
| - - nakedret |
32 |
| - # - prealloc |
33 |
| - - typecheck |
34 |
| - # - asciicheck |
35 | 9 | - bodyclose
|
36 | 10 | - copyloopvar
|
37 |
| - # - dogsled |
38 |
| - # - dupl |
| 11 | + - depguard |
39 | 12 | - dupword
|
40 | 13 | - errcheck
|
41 | 14 | - errorlint
|
42 |
| - # - exhaustive |
43 |
| - # - exportloopref |
44 |
| - # - funlen |
45 | 15 | - forbidigo
|
46 |
| - # - gci |
47 |
| - # - gochecknoglobals |
48 |
| - # - gochecknoinits |
49 |
| - # - gocognit |
50 |
| - # - goconst |
51 | 16 | - gocritic
|
52 |
| - # - gocyclo |
53 | 17 | - godot
|
54 |
| - # - godox |
55 |
| - - gofumpt |
56 |
| - # - goheader |
57 |
| - # - gomodguard |
58 |
| - # - goprintffuncname |
59 |
| - # - gosec |
60 |
| - - gosimple |
61 |
| - # - lll |
62 |
| - # - nestif |
63 |
| - # - nlreturn |
| 18 | + - govet |
| 19 | + - ineffassign |
| 20 | + - misspell |
| 21 | + - nakedret |
64 | 22 | - noctx
|
65 | 23 | - nolintlint
|
66 | 24 | - perfsprint
|
67 |
| - # - rowserrcheck |
68 |
| - # - sqlclosecheck |
69 |
| - - staticcheck |
70 |
| - # - stylecheck |
71 |
| - # - testpackage |
72 |
| - # - tparallel |
73 | 25 | - revive
|
74 |
| - # - unconvert |
75 |
| - # - unparam |
| 26 | + - staticcheck |
76 | 27 | - unused
|
77 | 28 | - whitespace
|
78 |
| - # - wrapcheck |
79 |
| - # - wsl |
80 |
| -linters-settings: |
81 |
| - depguard: |
| 29 | + settings: |
| 30 | + depguard: |
| 31 | + rules: |
| 32 | + main: |
| 33 | + deny: |
| 34 | + - pkg: golang.org/x/net/context |
| 35 | + desc: use the 'context' package from the standard library |
| 36 | + - pkg: math/rand$ |
| 37 | + desc: use the 'math/rand/v2' package |
| 38 | + errorlint: |
| 39 | + asserts: false |
| 40 | + forbidigo: |
| 41 | + forbid: |
| 42 | + - pattern: ^print(ln)?$ |
| 43 | + msg: Do not use builtin print functions. It's for bootstrapping only and may be removed in the future. |
| 44 | + - pattern: ^fmt\.Print.*$ |
| 45 | + msg: Do not use fmt.Print statements. |
| 46 | + - pattern: ^testing.T.Fatal.*$ |
| 47 | + msg: Use assert functions from the gotest.tools/v3/assert package instead. |
| 48 | + analyze-types: true |
| 49 | + gocritic: |
| 50 | + disabled-checks: |
| 51 | + - appendCombine |
| 52 | + - sloppyReassign |
| 53 | + - unlabelStmt |
| 54 | + - rangeValCopy |
| 55 | + - hugeParam |
| 56 | + - importShadow |
| 57 | + - sprintfQuotedString |
| 58 | + - builtinShadow |
| 59 | + - filepathJoin |
| 60 | + # See "Tags" section in https://github.com/go-critic/go-critic#usage |
| 61 | + enabled-tags: |
| 62 | + - diagnostic |
| 63 | + - performance |
| 64 | + - style |
| 65 | + - opinionated |
| 66 | + - experimental |
| 67 | + settings: |
| 68 | + ifElseChain: |
| 69 | + # Min number of if-else blocks that makes the warning trigger. |
| 70 | + minThreshold: 3 |
| 71 | + perfsprint: |
| 72 | + int-conversion: false |
| 73 | + err-error: false |
| 74 | + errorf: true |
| 75 | + sprintf1: false |
| 76 | + strconcat: false |
| 77 | + revive: |
| 78 | + # Set below 0.8 to enable error-strings |
| 79 | + confidence: 0.6 |
| 80 | + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md |
| 81 | + rules: |
| 82 | + - name: blank-imports |
| 83 | + - name: context-as-argument |
| 84 | + - name: context-keys-type |
| 85 | + - name: deep-exit |
| 86 | + - name: dot-imports |
| 87 | + arguments: |
| 88 | + - allowedPackages: |
| 89 | + - github.com/lima-vm/lima/pkg/must |
| 90 | + - name: empty-block |
| 91 | + - name: error-naming |
| 92 | + - name: error-return |
| 93 | + - name: error-strings |
| 94 | + - name: errorf |
| 95 | + - name: exported |
| 96 | + disabled: true |
| 97 | + - name: increment-decrement |
| 98 | + - name: indent-error-flow |
| 99 | + - name: package-comments |
| 100 | + disabled: true |
| 101 | + - name: range |
| 102 | + - name: receiver-naming |
| 103 | + - name: redefines-builtin-id |
| 104 | + - name: superfluous-else |
| 105 | + - name: time-naming |
| 106 | + - name: unexported-return |
| 107 | + - name: unreachable-code |
| 108 | + - name: unused-parameter |
| 109 | + - name: use-any |
| 110 | + - name: var-declaration |
| 111 | + - name: var-naming |
| 112 | + staticcheck: |
| 113 | + # https://staticcheck.dev/docs/configuration/options/#checks |
| 114 | + checks: |
| 115 | + - all |
| 116 | + - -QF* |
| 117 | + - -SA3000 # false positive for Go 1.15+. See https://github.com/golang/go/issues/34129 |
| 118 | + - -ST1000 |
| 119 | + - -ST1001 # duplicates revive.dot-imports |
| 120 | + - -ST1022 |
| 121 | + exclusions: |
| 122 | + presets: |
| 123 | + - common-false-positives |
| 124 | + - legacy |
| 125 | + - std-error-handling |
82 | 126 | rules:
|
83 |
| - main: |
84 |
| - deny: |
85 |
| - - pkg: "golang.org/x/net/context" |
86 |
| - desc: "use the 'context' package from the standard library" |
87 |
| - - pkg: "math/rand$" |
88 |
| - desc: "use the 'math/rand/v2' package" |
89 |
| - forbidigo: |
90 |
| - analyze-types: true |
91 |
| - forbid: |
92 |
| - - p: ^print(ln)?$ |
93 |
| - msg: Do not use builtin print functions. It's for bootstrapping only and may be removed in the future. |
94 |
| - - p: ^fmt\.Print.*$ |
95 |
| - msg: Do not use fmt.Print statements. |
96 |
| - - p: ^testing.T.Fatal.*$ |
97 |
| - msg: Use assert functions from the gotest.tools/v3/assert package instead. |
98 |
| - gocritic: |
99 |
| - # See "Tags" section in https://github.com/go-critic/go-critic#usage |
100 |
| - enabled-tags: |
101 |
| - - diagnostic |
102 |
| - - performance |
103 |
| - - style |
104 |
| - - opinionated |
105 |
| - - experimental |
106 |
| - disabled-checks: |
107 |
| - - appendCombine |
108 |
| - - sloppyReassign |
109 |
| - - unlabelStmt |
110 |
| - - rangeValCopy |
111 |
| - - hugeParam |
112 |
| - - importShadow |
113 |
| - - sprintfQuotedString |
114 |
| - - builtinShadow |
115 |
| - - filepathJoin |
116 |
| - settings: |
117 |
| - ifElseChain: |
118 |
| - # Min number of if-else blocks that makes the warning trigger. |
119 |
| - minThreshold: 3 |
120 |
| - errorlint: |
121 |
| - asserts: false |
122 |
| - perfsprint: |
123 |
| - int-conversion: false |
124 |
| - err-error: false |
125 |
| - errorf: true |
126 |
| - sprintf1: false |
127 |
| - strconcat: false |
128 |
| - revive: |
129 |
| - # Set below 0.8 to enable error-strings |
130 |
| - confidence: 0.6 |
131 |
| - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md |
132 |
| - rules: |
133 |
| - - name: blank-imports |
134 |
| - - name: context-as-argument |
135 |
| - - name: context-keys-type |
136 |
| - - name: deep-exit |
137 |
| - - name: dot-imports |
138 |
| - arguments: |
139 |
| - - allowedPackages: |
140 |
| - - github.com/lima-vm/lima/pkg/must |
141 |
| - - name: empty-block |
142 |
| - - name: error-naming |
143 |
| - - name: error-return |
144 |
| - - name: error-strings |
145 |
| - - name: errorf |
146 |
| - - name: exported |
147 |
| - - name: increment-decrement |
148 |
| - - name: indent-error-flow |
149 |
| - - name: package-comments |
150 |
| - - name: range |
151 |
| - - name: receiver-naming |
152 |
| - - name: redefines-builtin-id |
153 |
| - - name: superfluous-else |
154 |
| - - name: time-naming |
155 |
| - - name: unexported-return |
156 |
| - - name: unreachable-code |
157 |
| - - name: unused-parameter |
158 |
| - - name: use-any |
159 |
| - - name: var-declaration |
160 |
| - - name: var-naming |
161 |
| - staticcheck: |
162 |
| - # https://staticcheck.dev/docs/configuration/options/#checks |
163 |
| - checks: |
164 |
| - - "all" |
165 |
| - - "-SA3000" # false positive for Go 1.15+. See https://github.com/golang/go/issues/34129 |
| 127 | + # Allow using Uid, Gid in pkg/osutil. |
| 128 | + - path: pkg/osutil/ |
| 129 | + text: '(?i)(uid)|(gid)' |
| 130 | + # Disable some linters for test files. |
| 131 | + - linters: |
| 132 | + - godot |
| 133 | + path: _test\.go |
| 134 | + # Disable perfsprint for fmt.Sprint until https://github.com/catenacyber/perfsprint/issues/39 gets fixed. |
| 135 | + - linters: |
| 136 | + - perfsprint |
| 137 | + text: fmt.Sprint.* can be replaced with faster |
166 | 138 | issues:
|
167 | 139 | # Maximum issues count per one linter.
|
168 | 140 | max-issues-per-linter: 0
|
169 | 141 | # Maximum count of issues with the same text.
|
170 | 142 | max-same-issues: 0
|
171 |
| - include: |
172 |
| - - EXC0013 # revive: package comment should be of the form "(.+)..." |
173 |
| - - EXC0014 # revive: comment on exported (.+) should be of the form "(.+)..." |
174 |
| - exclude-rules: |
175 |
| - # Allow using Uid, Gid in pkg/osutil. |
176 |
| - - path: "pkg/osutil/" |
177 |
| - text: "uid" |
178 |
| - # Disable some linters for test files. |
179 |
| - - path: _test\.go |
180 |
| - linters: |
181 |
| - - godot |
182 |
| - # Disable revive.exported for constants. |
183 |
| - - text: "exported: comment on exported const" |
184 |
| - linters: |
185 |
| - - revive |
186 |
| - # Disable perfsprint for fmt.Sprint until https://github.com/catenacyber/perfsprint/issues/39 gets fixed. |
187 |
| - - text: "fmt.Sprint.* can be replaced with faster" |
188 |
| - linters: |
189 |
| - - perfsprint |
| 143 | +formatters: |
| 144 | + enable: |
| 145 | + - gofmt |
| 146 | + - gofumpt |
| 147 | + - goimports |
0 commit comments