Skip to content

Commit 60b4daa

Browse files
authored
go mod updates (#5629)
* go get github.com/containerd/containerd and golang.org/x/net * update k8s.io dependencies * go get github.com/spf13/afero * go get github.com/rook/rook * update golangci-lint * upgrade lint config * MANY lint fixes * more linters * MORE * the rest of the linters
1 parent c11d1ac commit 60b4daa

Some content is hidden

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

48 files changed

+561
-394
lines changed

.golangci.bck.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
run:
2+
allow-parallel-runners: true
3+
4+
issues:
5+
# don't skip warning about doc comments
6+
# don't exclude the default set of lint
7+
exclude-use-default: false
8+
9+
linters-settings:
10+
revive:
11+
rules:
12+
# The following rules are recommended https://github.com/mgechev/revive#recommended-configuration
13+
- name: blank-imports
14+
- name: context-as-argument
15+
- name: context-keys-type
16+
- name: dot-imports
17+
- name: error-return
18+
- name: error-strings
19+
disabled: true # TODO: fix errors first
20+
- name: error-naming
21+
- name: exported
22+
disabled: true # TODO: fix errors first
23+
- name: if-return
24+
- name: increment-decrement
25+
- name: var-naming
26+
disabled: true # Fails in places that you might cannot change pkg/rook/cephtypes/status.go:169:8: var-naming: struct field ZoneId should be ZoneID (revive)
27+
- name: var-declaration
28+
- name: package-comments
29+
disabled: true # TODO: fix errors first
30+
- name: range
31+
- name: receiver-naming
32+
- name: time-naming
33+
- name: unexported-return
34+
- name: indent-error-flow
35+
- name: errorf
36+
- name: empty-block
37+
- name: superfluous-else
38+
- name: unused-parameter
39+
- name: unreachable-code
40+
- name: redefines-builtin-id
41+
#
42+
# Rules in addition to the recommended configuration above.
43+
#
44+
- name: bool-literal-in-expr
45+
- name: constant-logical-expr
46+
47+
linters:
48+
disable-all: true
49+
enable:
50+
# - dupl (TODO remove the code duplications to sort it out)
51+
# - errcheck (TODO: Sort out f.Close() calls, we are not checking if they fails)
52+
- exportloopref
53+
- goconst
54+
# - gocyclo (TODO: Sort out the func with high complexity)
55+
- gofmt
56+
- goimports
57+
- gosimple
58+
- govet
59+
- ineffassign
60+
# - lll (TODO: Fiz size of the lines, as a good practice we should not need to use scroll to read the code)
61+
- misspell
62+
- nakedret
63+
- revive
64+
- staticcheck
65+
- typecheck
66+
# - unconvert TODO: check the 2 unnecessary conversions found to enable this one
67+
- unparam
68+
- unused

.golangci.yml

Lines changed: 164 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,170 @@
1+
version: "2"
12
run:
2-
deadline: 5m
33
allow-parallel-runners: true
4+
linters:
5+
default: none
6+
enable:
7+
- goconst
8+
- govet
9+
- ineffassign
10+
- misspell
11+
- nakedret
12+
- revive
13+
- staticcheck
14+
- unparam
15+
- unused
416

5-
issues:
6-
# don't skip warning about doc comments
7-
# don't exclude the default set of lint
8-
exclude-use-default: false
917

10-
linters-settings:
11-
govet:
12-
enable=fieldalignment: true
13-
revive:
14-
rules:
15-
# The following rules are recommended https://github.com/mgechev/revive#recommended-configuration
16-
- name: blank-imports
17-
- name: context-as-argument
18-
- name: context-keys-type
19-
- name: dot-imports
20-
- name: error-return
21-
- name: error-strings
22-
disabled: true # TODO: fix errors first
23-
- name: error-naming
24-
- name: exported
25-
disabled: true # TODO: fix errors first
26-
- name: if-return
27-
- name: increment-decrement
28-
- name: var-naming
29-
disabled: true # Fails in places that you might cannot change pkg/rook/cephtypes/status.go:169:8: var-naming: struct field ZoneId should be ZoneID (revive)
30-
- name: var-declaration
31-
- name: package-comments
32-
disabled: true # TODO: fix errors first
33-
- name: range
34-
- name: receiver-naming
35-
- name: time-naming
36-
- name: unexported-return
37-
- name: indent-error-flow
38-
- name: errorf
39-
- name: empty-block
40-
- name: superfluous-else
41-
- name: unused-parameter
42-
- name: unreachable-code
43-
- name: redefines-builtin-id
44-
#
45-
# Rules in addition to the recommended configuration above.
46-
#
47-
- name: bool-literal-in-expr
48-
- name: constant-logical-expr
4918

50-
linters:
51-
disable-all: true
19+
- asasalint
20+
- asciicheck
21+
- bidichk
22+
- bodyclose
23+
- canonicalheader
24+
- containedctx
25+
# - contextcheck
26+
- copyloopvar
27+
# - cyclop
28+
- decorder
29+
# - depguard
30+
- dogsled
31+
# - dupl
32+
# - dupword
33+
- durationcheck
34+
# - err113
35+
# - errcheck
36+
- errchkjson
37+
- errname
38+
- errorlint
39+
- exhaustive
40+
# - exhaustruct
41+
- exptostd
42+
- fatcontext
43+
# - forbidigo
44+
# - forcetypeassert
45+
# - funlen
46+
- ginkgolinter
47+
- gocheckcompilerdirectives
48+
# - gochecknoglobals
49+
# - gochecknoinits
50+
- gochecksumtype
51+
# - gocognit
52+
# - gocritic
53+
# - gocyclo
54+
# - godot
55+
# - godox
56+
- goheader
57+
# - gomoddirectives
58+
- gomodguard
59+
- goprintffuncname
60+
# - gosec
61+
- gosmopolitan
62+
- grouper
63+
- iface
64+
- importas
65+
- inamedparam
66+
- interfacebloat
67+
# - intrange
68+
# - ireturn
69+
# - lll
70+
71+
- loggercheck
72+
# - maintidx
73+
- makezero
74+
# - mirror
75+
# - mnd
76+
- musttag
77+
# - nestif
78+
- nilerr
79+
- nilnesserr
80+
# - nilnil
81+
# - nlreturn
82+
- noctx
83+
# - nolintlint
84+
# - nonamedreturns
85+
- nosprintfhostport
86+
# - paralleltest
87+
# - perfsprint
88+
# - prealloc
89+
- predeclared
90+
- promlinter
91+
- protogetter
92+
- reassign
93+
- recvcheck
94+
- rowserrcheck
95+
- sloglint
96+
- spancheck
97+
- sqlclosecheck
98+
- tagalign
99+
# - tagliatelle
100+
101+
- testableexamples
102+
- testifylint
103+
# - testpackage
104+
# - thelper
105+
- tparallel
106+
- unconvert
107+
- usestdlibvars
108+
- usetesting
109+
# - varnamelen
110+
- wastedassign
111+
# - whitespace
112+
# - wrapcheck
113+
# - wsl
114+
- zerologlint
115+
settings:
116+
revive:
117+
rules:
118+
- name: blank-imports
119+
- name: context-as-argument
120+
- name: context-keys-type
121+
- name: dot-imports
122+
- name: error-return
123+
- name: error-strings
124+
disabled: true
125+
- name: error-naming
126+
- name: exported
127+
disabled: true
128+
- name: if-return
129+
- name: increment-decrement
130+
- name: var-naming
131+
disabled: true
132+
- name: var-declaration
133+
- name: package-comments
134+
disabled: true
135+
- name: range
136+
- name: receiver-naming
137+
- name: time-naming
138+
- name: unexported-return
139+
- name: indent-error-flow
140+
- name: errorf
141+
- name: empty-block
142+
- name: superfluous-else
143+
- name: unused-parameter
144+
- name: unreachable-code
145+
- name: redefines-builtin-id
146+
- name: bool-literal-in-expr
147+
- name: constant-logical-expr
148+
staticcheck:
149+
checks:
150+
- all
151+
- '-SA1006' # disable the rule SA1006 - this falsely flags using 'fmt.Errorf' with a string literal
152+
- '-ST1005' # disable the rule ST1005 - this warns against log lines with a leading capital letter which we use for some CLI output
153+
- '-ST1000' # disable the rule ST1000 - this requires a comment for all packages
154+
- '-ST1003' # disable the rule ST1000 - rules for names
155+
exclusions:
156+
generated: lax
157+
paths:
158+
- third_party$
159+
- builtin$
160+
- examples$
161+
formatters:
52162
enable:
53-
# - dupl (TODO remove the code duplications to sort it out)
54-
# - errcheck (TODO: Sort out f.Close() calls, we are not checking if they fails)
55-
- exportloopref
56-
- goconst
57-
# - gocyclo (TODO: Sort out the func with high complexity)
58-
- gofmt
59-
- goimports
60-
- gosimple
61-
- govet
62-
- ineffassign
63-
# - lll (TODO: Fiz size of the lines, as a good practice we should not need to use scroll to read the code)
64-
- misspell
65-
- nakedret
66-
- revive
67-
- staticcheck
68-
- typecheck
69-
# - unconvert TODO: check the 2 unnecessary conversions found to enable this one
70-
- unparam
71-
- unused
163+
- gofmt
164+
- goimports
165+
exclusions:
166+
generated: lax
167+
paths:
168+
- third_party$
169+
- builtin$
170+
- examples$

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -607,20 +607,20 @@ GOLANGCI_LINT = $(shell go env GOPATH)/bin/golangci-lint
607607
golangci-lint:
608608
@[ -f $(GOLANGCI_LINT) ] || { \
609609
set -e ;\
610-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.55.2 ;\
610+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v2.0.2 ;\
611611
}
612612

613613
.PHONY: lint
614614
lint: golangci-lint ## Run golangci-lint and vet linter
615-
$(GOLANGCI_LINT) --build-tags "${BUILDTAGS}" run --timeout 10m ./cmd/... ./pkg/... ./kurl_util/...
615+
GOOS=linux $(GOLANGCI_LINT) --build-tags "${BUILDTAGS}" run --timeout 10m ./cmd/... ./pkg/... ./kurl_util/...
616616

617617
.PHONY: lint-fix
618618
lint-fix: golangci-lint ## Run golangci-lint linter and perform small fixes
619-
$(GOLANGCI_LINT) --build-tags "${BUILDTAGS}" run --fix --timeout 10m ./cmd/... ./pkg/... ./kurl_util/...
619+
GOOS=linux $(GOLANGCI_LINT) --build-tags "${BUILDTAGS}" run --fix --timeout 10m ./cmd/... ./pkg/... ./kurl_util/...
620620

621621
.PHONY: vet
622622
vet: ## Go vet the code
623-
go vet ${BUILDFLAGS} ./cmd/... ./pkg/...
623+
GOOS=linux go vet ${BUILDFLAGS} ./cmd/... ./pkg/...
624624

625625
.PHONY: test
626626
test: lint vet ## Check the code with linters and vet

0 commit comments

Comments
 (0)