Skip to content

Commit 1bf3e3c

Browse files
committed
Upgrade golangci-lint to v2
Signed-off-by: Oleksandr Redko <[email protected]>
1 parent 0625d0b commit 1bf3e3c

File tree

5 files changed

+143
-185
lines changed

5 files changed

+143
-185
lines changed

Diff for: .github/workflows/test.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ jobs:
3939
- name: Verify generated files
4040
run: make install-tools generate check-generated
4141
- name: Run golangci-lint
42-
uses: golangci/golangci-lint-action@55c2c1448f86e01eaae002a5a3a9624417608d84 # v6.5.2
42+
uses: golangci/golangci-lint-action@dec74fa03096ff515422f71d18d41307cacde373 # v7.0.0
4343
with:
44-
version: v1.64.2
45-
args: --verbose --timeout=10m
44+
version: v2.0.0
45+
args: --verbose
4646
- name: Run yamllint
4747
run: yamllint .
4848
- name: Install shellcheck

Diff for: .golangci.yml

+123-165
Original file line numberDiff line numberDiff line change
@@ -1,189 +1,147 @@
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"
194
run:
205
concurrency: 6
21-
timeout: 2m # to avoid timeout locally
226
linters:
23-
disable-all: true
7+
default: none
248
enable:
25-
- depguard
26-
- gofmt
27-
- goimports
28-
- govet
29-
- ineffassign
30-
- misspell
31-
- nakedret
32-
# - prealloc
33-
- typecheck
34-
# - asciicheck
359
- bodyclose
3610
- copyloopvar
37-
# - dogsled
38-
# - dupl
11+
- depguard
3912
- dupword
4013
- errcheck
4114
- errorlint
42-
# - exhaustive
43-
# - exportloopref
44-
# - funlen
4515
- forbidigo
46-
# - gci
47-
# - gochecknoglobals
48-
# - gochecknoinits
49-
# - gocognit
50-
# - goconst
5116
- gocritic
52-
# - gocyclo
5317
- 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
6422
- noctx
6523
- nolintlint
6624
- perfsprint
67-
# - rowserrcheck
68-
# - sqlclosecheck
69-
- staticcheck
70-
# - stylecheck
71-
# - testpackage
72-
# - tparallel
7325
- revive
74-
# - unconvert
75-
# - unparam
26+
- staticcheck
7627
- unused
7728
- 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
82126
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
166138
issues:
167139
# Maximum issues count per one linter.
168140
max-issues-per-linter: 0
169141
# Maximum count of issues with the same text.
170142
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

Comments
 (0)