Skip to content

Commit a278fd2

Browse files
committed
update golangci-lint version
Signed-off-by: dongjiang <[email protected]>
1 parent 20e4ae2 commit a278fd2

File tree

4 files changed

+97
-84
lines changed

4 files changed

+97
-84
lines changed

.github/workflows/golangci-lint.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ jobs:
3131
with:
3232
go-version: ${{ steps.vars.outputs.go_version }}
3333
- name: golangci-lint
34-
uses: golangci/golangci-lint-action@55c2c1448f86e01eaae002a5a3a9624417608d84 # tag=v6.5.2
34+
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # tag=v8.0.0
3535
with:
36-
version: v1.64.8
37-
args: --out-format=colored-line-number
36+
version: v2.1.6
37+
args: --output.text.print-linter-name=true --output.text.colors=true --timeout 10m
3838
working-directory: ${{matrix.working-directory}}

.golangci.yml

Lines changed: 91 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1+
version: "2"
12
run:
2-
allow-parallel-runners: true
3-
modules-download-mode: readonly
4-
# Increase the default deadline from 1m as some module operations can take a
5-
# while if uncached!
6-
timeout: 10m
73
go: "1.24"
8-
4+
timeout: 10m
5+
modules-download-mode: readonly
6+
allow-parallel-runners: true
97
linters:
108
# sync from https://github.com/kubernetes-sigs/controller-runtime/blob/main/.golangci.yml
11-
disable-all: true
9+
default: none
1210
enable:
1311
- asasalint
1412
- asciicheck
@@ -25,10 +23,7 @@ linters:
2523
- goconst
2624
- gocritic
2725
- gocyclo
28-
- gofmt
29-
- goimports
3026
- goprintffuncname
31-
- gosimple
3227
- govet
3328
- importas
3429
- ineffassign
@@ -40,74 +35,95 @@ linters:
4035
- prealloc
4136
- revive
4237
- staticcheck
43-
- stylecheck
4438
- tagliatelle
45-
- typecheck
4639
- unconvert
4740
- unparam
4841
- unused
4942
- whitespace
50-
51-
issues:
52-
exclude-rules:
53-
# Dot imports for gomega and ginkgo are allowed
54-
# within test files.
55-
- path: _test\.go
56-
text: should not use dot imports
57-
# Ignore error type switch case
58-
- path: "pkg/loader/loader.go"
59-
linters:
60-
- errorlint
61-
# Ignore test files
62-
- linters:
63-
- dupl
64-
- ginkgolinter
65-
path: _test\.go
66-
- linters:
67-
- gocritic
68-
path: "pkg/markers/help.go"
69-
- linters:
70-
- exhaustive
71-
path: "pkg/markers/parse.go|pkg/deepcopy/traverse.go|pkg/genall/help/types.go|pkg/crd/schema.go|pkg/crd/flatten.go"
72-
# Ignore consider pre-allocating variables
73-
- linters:
74-
- prealloc
75-
text: Consider pre-allocating
76-
linters-settings:
77-
govet:
78-
enable-all: true
79-
disable:
80-
- fieldalignment
81-
- shadow
82-
importas:
83-
no-unaliased: true
84-
revive:
85-
# By default, revive will enable only the linting rules that are named in the configuration file.
86-
# So, it's needed to explicitly enable all required rules here.
43+
settings:
44+
govet:
45+
disable:
46+
- fieldalignment
47+
- shadow
48+
enable-all: true
49+
importas:
50+
no-unaliased: true
51+
revive:
52+
# By default, revive will enable only the linting rules that are named in the configuration file.
53+
# So, it's needed to explicitly enable all required rules here.
54+
rules:
55+
# The following rules are recommended https://github.com/mgechev/revive#recommended-configuration
56+
- name: blank-imports
57+
- name: context-as-argument
58+
- name: context-keys-type
59+
- name: dot-imports
60+
- name: error-return
61+
- name: error-strings
62+
- name: error-naming
63+
- name: if-return
64+
- name: increment-decrement
65+
- name: var-naming
66+
- name: var-declaration
67+
- name: range
68+
- name: receiver-naming
69+
- name: time-naming
70+
- name: unexported-return
71+
- name: indent-error-flow
72+
- name: errorf
73+
- name: superfluous-else
74+
- name: unreachable-code
75+
- name: redefines-builtin-id
76+
#
77+
# Rules in addition to the recommended configuration above.
78+
#
79+
- name: bool-literal-in-expr
80+
- name: constant-logical-expr
81+
exclusions:
82+
generated: strict
83+
paths:
84+
- zz_generated.*\.go$
85+
- .*conversion.*\.go$
86+
presets:
87+
- comments
88+
- common-false-positives
89+
- legacy
90+
- std-error-handling
8791
rules:
88-
# The following rules are recommended https://github.com/mgechev/revive#recommended-configuration
89-
- name: blank-imports
90-
- name: context-as-argument
91-
- name: context-keys-type
92-
- name: dot-imports
93-
- name: error-return
94-
- name: error-strings
95-
- name: error-naming
96-
- name: if-return
97-
- name: increment-decrement
98-
- name: var-naming
99-
- name: var-declaration
100-
- name: range
101-
- name: receiver-naming
102-
- name: time-naming
103-
- name: unexported-return
104-
- name: indent-error-flow
105-
- name: errorf
106-
- name: superfluous-else
107-
- name: unreachable-code
108-
- name: redefines-builtin-id
109-
#
110-
# Rules in addition to the recommended configuration above.
111-
#
112-
- name: bool-literal-in-expr
113-
- name: constant-logical-expr
92+
# Dot imports for gomega and ginkgo are allowed
93+
# within test files.
94+
- linters:
95+
- revive
96+
path: _test\.go
97+
text: should not use dot imports
98+
# Ignore error type switch case
99+
- linters:
100+
- errorlint
101+
path: pkg/loader/loader.go
102+
# Ignore test files
103+
- linters:
104+
- dupl
105+
- ginkgolinter
106+
path: _test\.go
107+
- linters:
108+
- gocritic
109+
path: pkg/markers/help.go
110+
- linters:
111+
- exhaustive
112+
path: pkg/markers/parse.go|pkg/deepcopy/traverse.go|pkg/genall/help/types.go|pkg/crd/schema.go|pkg/crd/flatten.go
113+
# Ignore consider pre-allocating variables
114+
- linters:
115+
- prealloc
116+
text: Consider pre-allocating
117+
- linters:
118+
- staticcheck
119+
path: (.+)\.go$
120+
text: (QF1008)
121+
formatters:
122+
enable:
123+
- gofmt
124+
- goimports
125+
exclusions:
126+
generated: strict
127+
paths:
128+
- zz_generated.*\.go$
129+
- .*conversion.*\.go$

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ GO_INSTALL := ./hack/go-install.sh
6363
GOLANGCI_LINT_BIN := golangci-lint
6464
GOLANGCI_LINT_VER := $(shell cat .github/workflows/golangci-lint.yml | grep [[:space:]]version: | sed 's/.*version: //')
6565
GOLANGCI_LINT := $(abspath $(TOOLS_BIN_DIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER))
66-
GOLANGCI_LINT_PKG := github.com/golangci/golangci-lint/cmd/golangci-lint
66+
GOLANGCI_LINT_PKG := github.com/golangci/golangci-lint/v2/cmd/golangci-lint
6767

6868
$(GOLANGCI_LINT): # Build golangci-lint from tools folder.
6969
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) $(GOLANGCI_LINT_PKG) $(GOLANGCI_LINT_BIN) $(GOLANGCI_LINT_VER)

pkg/markers/parse.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -868,11 +868,8 @@ func (d *Definition) Parse(rawMarker string) (interface{}, error) {
868868
seen[""] = struct{}{} // mark as seen for strict definitions
869869
} else if !d.Empty() && scanner.Peek() != sc.EOF {
870870
// if we expect *and* actually have arguments passed
871-
for {
872-
// parse the argument name
873-
if !expect(scanner, sc.Ident, "argument name") {
874-
break
875-
}
871+
// parse the argument name
872+
for expect(scanner, sc.Ident, "argument name") {
876873
argName := scanner.TokenText()
877874
if !expect(scanner, '=', "equals") {
878875
break

0 commit comments

Comments
 (0)