Skip to content

Commit d498889

Browse files
Merge pull request #25726 from kolyshkin/golangci-v2
Golangci v2
2 parents 6940839 + 4eb75f6 commit d498889

File tree

111 files changed

+378
-608
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+378
-608
lines changed

.codespellrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
skip = bin,vendor,.git,go.sum,.cirrus.yml,"*.fish,RELEASE_NOTES.md,*.xz,*.gz,*.ps1,*.tar,swagger.yaml,*.tgz,bin2img,*ico,*.png,*.1,*.5,copyimg,*.orig,apidoc.go
44
check-hidden = true
55
ignore-regex = \b(Not|assert)In\b
6-
ignore-words-list = ddress,secon,passt,bu,hastable,te,clos,ans,pullrequest,uint,iff,od,seeked,splitted,marge,erro,hist,ether,specif,whit
6+
ignore-words-list = ddress,secon,passt,bu,hastable,te,clos,ans,pullrequest,uint,iff,od,seeked,splitted,marge,erro,hist,ether,specif,whit,decorder

.golangci.yml

Lines changed: 74 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,82 @@
1-
---
1+
version: "2"
22
run:
3-
concurrency: 6
4-
timeout: 5m
53
modules-download-mode: readonly
4+
5+
formatters:
6+
enable:
7+
- gofmt
8+
- goimports
9+
exclusions:
10+
generated: strict
11+
612
linters:
7-
enable-all: true
8-
disable:
9-
# too many reports but requires attention
10-
- depguard
11-
- intrange # should be turned on but we have to convert each place manually as there is no auto fix function
12-
- tagalign
13-
- perfsprint
14-
- typecheck
15-
# useful hints that should be addressed
16-
- testifylint # all of reports that should be fixed
17-
- nakedret
18-
- gosmopolitan # usage of time.Local in pkg/k8s.io
19-
- tagliatelle # too many JSON keys cannot be changed due to compat
20-
- dupword # too many false positives (e.g., in tests)
21-
- gocognit
22-
- testpackage
23-
- err113
24-
- errorlint
25-
- wrapcheck
26-
- paralleltest
27-
- wsl
28-
- godox
29-
- tparallel
30-
- nlreturn
31-
- noctx
32-
- nestif
33-
- predeclared
34-
- thelper
35-
- forbidigo
36-
- exhaustive
37-
- gofumpt
38-
- gci
39-
- godot
40-
- dupl
41-
- funlen
42-
- gochecknoglobals
43-
- gochecknoinits
44-
- goconst
45-
- gocyclo
46-
- lll
47-
- gosec
48-
- musttag # way to many warnings to fix for now, also some false positives
49-
- mnd # way to many false positives
50-
- gomoddirectives
51-
- containedctx
52-
- contextcheck
53-
- cyclop
54-
- canonicalheader # our current header values are fixed and should not be changed
55-
- errname
56-
- forcetypeassert
57-
- ireturn
58-
- varnamelen
59-
- maintidx
60-
- nilnil
61-
- nonamedreturns
62-
- exhaustruct
63-
# deprecated linters
64-
- tenv
65-
linters-settings:
66-
errcheck:
67-
check-blank: false
68-
nolintlint:
69-
allow-unused: true
70-
require-specific: true
71-
revive:
13+
enable:
14+
- asasalint
15+
- asciicheck
16+
- bidichk
17+
- bodyclose
18+
- copyloopvar
19+
- decorder
20+
- dogsled
21+
- durationcheck
22+
- errchkjson
23+
- exptostd
24+
- fatcontext
25+
- ginkgolinter
26+
- gocheckcompilerdirectives
27+
- gochecksumtype
28+
- gocritic
29+
- goprintffuncname
30+
- grouper
31+
- iface
32+
- inamedparam
33+
- interfacebloat
34+
- makezero
35+
- mirror
36+
- misspell
37+
- nilerr
38+
- nilnesserr
39+
- nolintlint
40+
- nosprintfhostport
41+
- prealloc
42+
- protogetter
43+
- reassign
44+
- recvcheck
45+
- revive
46+
- rowserrcheck
47+
- sqlclosecheck
48+
- staticcheck
49+
- testableexamples
50+
- unconvert
51+
- unparam
52+
- usestdlibvars
53+
- usetesting
54+
- wastedassign
55+
- whitespace
56+
settings:
57+
staticcheck:
58+
checks:
59+
- all
60+
- -ST1003 # https://staticcheck.dev/docs/checks/#ST1003 Poorly chosen identifier.
61+
- -QF1008 # https://staticcheck.dev/docs/checks/#QF1008 Omit embedded fields from selector expression.
62+
nolintlint:
63+
require-specific: true
64+
revive:
65+
rules:
66+
- name: unused-parameter
67+
disabled: true
68+
exclusions:
69+
generated: strict
70+
presets:
71+
- comments
72+
- common-false-positives
73+
- legacy
74+
- std-error-handling
7275
rules:
73-
- name: unused-parameter
74-
disabled: true
76+
- linters:
77+
- recvcheck
78+
path: pkg/k8s.io/
7579

7680
issues:
77-
# Maximum issues count per one linter.
78-
# Set to 0 to disable.
79-
# Default: 50
8081
max-issues-per-linter: 0
81-
# Maximum count of issues with the same text.
82-
# Set to 0 to disable.
83-
# Default: 3
8482
max-same-issues: 0
85-
exclude-dirs-use-default: true
86-
exclude-dirs:
87-
- contrib
88-
- dependencies
89-
exclude-files:
90-
- swagger.go
91-
exclude-rules:
92-
# Exclude recvcheck from running on the imported k8s files, to much failures
93-
- path: pkg/k8s.io/
94-
linters:
95-
- recvcheck

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ BUILDTAGS += ${EXTRA_BUILDTAGS}
6161
# N/B: This value is managed by Renovate, manual changes are
6262
# possible, as long as they don't disturb the formatting
6363
# (i.e. DO NOT ADD A 'v' prefix!)
64-
GOLANGCI_LINT_VERSION := 1.64.4
64+
GOLANGCI_LINT_VERSION := 2.0.2
6565
PYTHON ?= $(shell command -v python3 python|head -n1)
6666
PKG_MANAGER ?= $(shell command -v dnf yum|head -n1)
6767
# ~/.local/bin is not in PATH on all systems
@@ -282,7 +282,7 @@ endif
282282

283283
.PHONY: golangci-lint
284284
golangci-lint: .install.golangci-lint
285-
hack/golangci-lint.sh run
285+
hack/golangci-lint.sh
286286

287287
.PHONY: test/checkseccomp/checkseccomp
288288
test/checkseccomp/checkseccomp: $(wildcard test/checkseccomp/*.go)

cmd/podman-wslkerninst/main.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,9 @@ import (
1616
)
1717

1818
const (
19-
//nolint:stylecheck
2019
MB_ICONWARNING = 0x00000030
21-
//nolint:stylecheck
22-
MB_OK = 0x00000000
23-
//nolint:stylecheck
24-
MB_DEFBUTTON1 = 0x00000000
20+
MB_OK = 0x00000000
21+
MB_DEFBUTTON1 = 0x00000000
2522
)
2623

2724
const KernelWarning = "WSL Kernel installation did not complete successfully. " +

cmd/podman/containers/stats.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,10 @@ func combineBytesValues(a, b uint64) string {
252252

253253
func outputJSON(stats []containerStats) error {
254254
type jstat struct {
255-
Id string `json:"id"` //nolint:revive,stylecheck
255+
Id string `json:"id"`
256256
Name string `json:"name"`
257257
CPUTime string `json:"cpu_time"`
258-
CpuPercent string `json:"cpu_percent"` //nolint:revive,stylecheck
258+
CpuPercent string `json:"cpu_percent"`
259259
AverageCPU string `json:"avg_cpu"`
260260
MemUsage string `json:"mem_usage"`
261261
MemPerc string `json:"mem_percent"`

cmd/podman/images/search.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func imageSearch(cmd *cobra.Command, args []string) error {
164164
isJSON := report.IsJSON(searchOptions.Format)
165165
for i, element := range searchReport {
166166
d := strings.ReplaceAll(element.Description, "\n", " ")
167-
if len(d) > 44 && !(searchOptions.NoTrunc || isJSON) {
167+
if len(d) > 44 && (!searchOptions.NoTrunc && !isJSON) {
168168
d = strings.TrimSpace(d[:44]) + "..."
169169
}
170170
searchReport[i].Description = d

cmd/podman/pods/ps.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ func (l ListPodReporter) ID() string {
221221
}
222222

223223
// Id returns the Pod id
224-
func (l ListPodReporter) Id() string { //nolint:revive,stylecheck
224+
func (l ListPodReporter) Id() string {
225225
if noTrunc {
226226
return l.ListPodsReport.Id
227227
}
@@ -235,7 +235,7 @@ func (l ListPodReporter) InfraID() string {
235235

236236
// InfraId returns the infra container id for the pod
237237
// depending on trunc
238-
func (l ListPodReporter) InfraId() string { //nolint:revive,stylecheck
238+
func (l ListPodReporter) InfraId() string {
239239
if len(l.ListPodsReport.InfraId) == 0 {
240240
return ""
241241
}

cmd/podman/system/migrate.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ func migrate(cmd *cobra.Command, args []string) {
5858

5959
// FIXME change this to return the error like other commands
6060
// defer will never run on os.Exit()
61-
//nolint:gocritic
6261
os.Exit(define.ExecErrorCodeGeneric)
6362
}
6463
os.Exit(0)

cmd/podman/system/renumber.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ func init() {
3838
Parent: systemCmd,
3939
})
4040
}
41+
4142
func renumber(cmd *cobra.Command, args []string) {
4243
if err := registry.ContainerEngine().Renumber(registry.Context()); err != nil {
4344
fmt.Println(err)
4445
// FIXME change this to return the error like other commands
4546
// defer will never run on os.Exit()
46-
//nolint:gocritic
4747
os.Exit(define.ExecErrorCodeGeneric)
4848
}
4949
os.Exit(0)

cmd/rootlessport/wsl.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build linux
2+
13
package main
24

35
import (

0 commit comments

Comments
 (0)