Skip to content

Commit 84fb7b5

Browse files
authored
Merge pull request kubernetes#121504 from pohly/golangci-lint-godoc
golangci-lint: enable doc comment checking for cmd/kubeadm
2 parents e8d4559 + 39df946 commit 84fb7b5

File tree

4 files changed

+90
-4
lines changed

4 files changed

+90
-4
lines changed

hack/golangci-hints.yaml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ output:
2424
issues:
2525
max-issues-per-linter: 0
2626
max-same-issues: 0
27+
28+
# The default excludes disable the "should have comment or be unexported" check from revive.
29+
# We want that to be enabled, therefore we have to disable all default excludes and
30+
# add those back one-by-one that we want. See https://github.com/golangci/golangci-lint/issues/456#issuecomment-617470264
31+
exclude-use-default: false
32+
exclude:
33+
# staticcheck: Developers tend to write in C-style with an explicit 'break' in a 'switch', so it's ok to ignore
34+
- ineffective break statement. Did you mean to break out of the outer loop
35+
2736
# Excluding configuration per-path, per-linter, per-text and per-source
2837
exclude-rules:
2938
# exclude ineffassign linter for generated files for conversion
@@ -45,7 +54,8 @@ issues:
4554
# https://github.com/kubernetes/kubernetes/issues/117288#issuecomment-1514201592
4655
- linters:
4756
- stylecheck
48-
text: "ST1003: should not use underscores in Go names; func (Convert_.*_To_.*|SetDefaults_)"
57+
- revive
58+
text: "(ST1003: should not use underscores in Go names; func (Convert_.*_To_.*|SetDefaults_)|exported: exported function (Convert|SetDefaults)_.* should be of the form)"
4959

5060
# This check currently has some false positives (https://github.com/nunnatsa/ginkgolinter/issues/91).
5161
- linters:
@@ -66,6 +76,7 @@ linters:
6676
- govet
6777
- ineffassign
6878
- logcheck
79+
- revive
6980
- staticcheck
7081
- stylecheck
7182
- unused
@@ -86,6 +97,12 @@ linters-settings: # please keep this alphabetized
8697
- p: \.Extract
8798
pkg: ^k8s\.io/client-go/applyconfigurations/
8899
msg: should not be used because managedFields was removed
100+
revive:
101+
# Only these rules are enabled.
102+
rules:
103+
- name: exported
104+
arguments:
105+
- disableStutteringCheck
89106
staticcheck:
90107
checks:
91108
- "all"

hack/golangci-strict.yaml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ output:
2424
issues:
2525
max-issues-per-linter: 0
2626
max-same-issues: 0
27+
28+
# The default excludes disable the "should have comment or be unexported" check from revive.
29+
# We want that to be enabled, therefore we have to disable all default excludes and
30+
# add those back one-by-one that we want. See https://github.com/golangci/golangci-lint/issues/456#issuecomment-617470264
31+
exclude-use-default: false
32+
exclude:
33+
# staticcheck: Developers tend to write in C-style with an explicit 'break' in a 'switch', so it's ok to ignore
34+
- ineffective break statement. Did you mean to break out of the outer loop
35+
2736
# Excluding configuration per-path, per-linter, per-text and per-source
2837
exclude-rules:
2938
# exclude ineffassign linter for generated files for conversion
@@ -45,7 +54,8 @@ issues:
4554
# https://github.com/kubernetes/kubernetes/issues/117288#issuecomment-1514201592
4655
- linters:
4756
- stylecheck
48-
text: "ST1003: should not use underscores in Go names; func (Convert_.*_To_.*|SetDefaults_)"
57+
- revive
58+
text: "(ST1003: should not use underscores in Go names; func (Convert_.*_To_.*|SetDefaults_)|exported: exported function (Convert|SetDefaults)_.* should be of the form)"
4959

5060
# This check currently has some false positives (https://github.com/nunnatsa/ginkgolinter/issues/91).
5161
- linters:
@@ -83,6 +93,12 @@ issues:
8393
- gosimple
8494
text: "S1033: unnecessary guard around call to delete"
8595

96+
# Only packages listed here opt into the strict "exported symbols must be documented".
97+
- linters:
98+
- revive
99+
text: "(exported: exported .* or be unexported|exported: comment on exported.*should be of the form)"
100+
path-except: cmd/kubeadm
101+
86102
# Didn't make it into https://github.com/kubernetes/kubernetes/issues/117288.
87103
# Discussion on Slack concluded that "it's hard to have a universal policy for all
88104
# functions marked deprecated" and thus this can only be a hint which must
@@ -110,6 +126,7 @@ linters:
110126
- govet
111127
- ineffassign
112128
- logcheck
129+
- revive
113130
- staticcheck
114131
- stylecheck
115132
- unused
@@ -133,6 +150,12 @@ linters-settings: # please keep this alphabetized
133150
- p: \.Extract
134151
pkg: ^k8s\.io/client-go/applyconfigurations/
135152
msg: should not be used because managedFields was removed
153+
revive:
154+
# Only these rules are enabled.
155+
rules:
156+
- name: exported
157+
arguments:
158+
- disableStutteringCheck
136159
staticcheck:
137160
checks:
138161
- "all"

hack/golangci.yaml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ output:
2424
issues:
2525
max-issues-per-linter: 0
2626
max-same-issues: 0
27+
28+
# The default excludes disable the "should have comment or be unexported" check from revive.
29+
# We want that to be enabled, therefore we have to disable all default excludes and
30+
# add those back one-by-one that we want. See https://github.com/golangci/golangci-lint/issues/456#issuecomment-617470264
31+
exclude-use-default: false
32+
exclude:
33+
# staticcheck: Developers tend to write in C-style with an explicit 'break' in a 'switch', so it's ok to ignore
34+
- ineffective break statement. Did you mean to break out of the outer loop
35+
2736
# Excluding configuration per-path, per-linter, per-text and per-source
2837
exclude-rules:
2938
# exclude ineffassign linter for generated files for conversion
@@ -51,7 +60,8 @@ issues:
5160
# https://github.com/kubernetes/kubernetes/issues/117288#issuecomment-1514201592
5261
- linters:
5362
- stylecheck
54-
text: "ST1003: should not use underscores in Go names; func (Convert_.*_To_.*|SetDefaults_)"
63+
- revive
64+
text: "(ST1003: should not use underscores in Go names; func (Convert_.*_To_.*|SetDefaults_)|exported: exported function (Convert|SetDefaults)_.* should be of the form)"
5565

5666
# This check currently has some false positives (https://github.com/nunnatsa/ginkgolinter/issues/91).
5767
- linters:
@@ -89,6 +99,12 @@ issues:
8999
- gosimple
90100
text: "S1033: unnecessary guard around call to delete"
91101

102+
# Only packages listed here opt into the strict "exported symbols must be documented".
103+
- linters:
104+
- revive
105+
text: "(exported: exported .* or be unexported|exported: comment on exported.*should be of the form)"
106+
path-except: cmd/kubeadm
107+
92108
# Didn't make it into https://github.com/kubernetes/kubernetes/issues/117288.
93109
# Discussion on Slack concluded that "it's hard to have a universal policy for all
94110
# functions marked deprecated" and thus this can only be a hint which must
@@ -116,6 +132,7 @@ linters:
116132
- govet
117133
- ineffassign
118134
- logcheck
135+
- revive
119136
- staticcheck
120137
- stylecheck
121138
- unused
@@ -140,6 +157,12 @@ linters-settings: # please keep this alphabetized
140157
enabled-checks:
141158
- equalFold
142159
- boolExprSimplify
160+
revive:
161+
# Only these rules are enabled.
162+
rules:
163+
- name: exported
164+
arguments:
165+
- disableStutteringCheck
143166
staticcheck:
144167
checks:
145168
- "all"

hack/golangci.yaml.in

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ output:
2424
issues:
2525
max-issues-per-linter: 0
2626
max-same-issues: 0
27+
28+
# The default excludes disable the "should have comment or be unexported" check from revive.
29+
# We want that to be enabled, therefore we have to disable all default excludes and
30+
# add those back one-by-one that we want. See https://github.com/golangci/golangci-lint/issues/456#issuecomment-617470264
31+
exclude-use-default: false
32+
exclude:
33+
# staticcheck: Developers tend to write in C-style with an explicit 'break' in a 'switch', so it's ok to ignore
34+
- ineffective break statement. Did you mean to break out of the outer loop
35+
2736
# Excluding configuration per-path, per-linter, per-text and per-source
2837
exclude-rules:
2938
# exclude ineffassign linter for generated files for conversion
@@ -54,7 +63,8 @@ issues:
5463
# https://github.com/kubernetes/kubernetes/issues/117288#issuecomment-1514201592
5564
- linters:
5665
- stylecheck
57-
text: "ST1003: should not use underscores in Go names; func (Convert_.*_To_.*|SetDefaults_)"
66+
- revive
67+
text: "(ST1003: should not use underscores in Go names; func (Convert_.*_To_.*|SetDefaults_)|exported: exported function (Convert|SetDefaults)_.* should be of the form)"
5868

5969
# This check currently has some false positives (https://github.com/nunnatsa/ginkgolinter/issues/91).
6070
- linters:
@@ -94,6 +104,12 @@ issues:
94104
- gosimple
95105
text: "S1033: unnecessary guard around call to delete"
96106

107+
# Only packages listed here opt into the strict "exported symbols must be documented".
108+
- linters:
109+
- revive
110+
text: "(exported: exported .* or be unexported|exported: comment on exported.*should be of the form)"
111+
path-except: cmd/kubeadm
112+
97113
# Didn't make it into https://github.com/kubernetes/kubernetes/issues/117288.
98114
# Discussion on Slack concluded that "it's hard to have a universal policy for all
99115
# functions marked deprecated" and thus this can only be a hint which must
@@ -122,6 +138,7 @@ linters:
122138
- govet
123139
- ineffassign
124140
- logcheck
141+
- revive
125142
- staticcheck
126143
- stylecheck
127144
- unused
@@ -153,6 +170,12 @@ linters-settings: # please keep this alphabetized
153170
- equalFold
154171
- boolExprSimplify
155172
{{- end}}
173+
revive:
174+
# Only these rules are enabled.
175+
rules:
176+
- name: exported
177+
arguments:
178+
- disableStutteringCheck
156179
staticcheck:
157180
checks:
158181
- "all"

0 commit comments

Comments
 (0)