Skip to content

Commit cd939cc

Browse files
authored
Add godoclint (#4077)
1 parent 38baadc commit cd939cc

File tree

19 files changed

+187
-17
lines changed

19 files changed

+187
-17
lines changed

.godoclint.yaml

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# Configuration file version.
2+
version: "1.0"
3+
4+
# List of regexp patterns matching files the linter should include. When
5+
# omitted/null, the linter includes all Go files. If assigned then only the
6+
# files that their relative path (with respect to the config file path) matches
7+
# any of the patterns will be processed.
8+
#
9+
# Note: The patterns must assume a Unix-like path (i.e., separated with forward
10+
# slashes, `/`), even on Windows. This is to ensure a consistent behavior across
11+
# different platforms.
12+
#
13+
# Example:
14+
# include:
15+
# - ^pkg/
16+
# - _foo.go$
17+
include: null
18+
19+
# List of regexp patterns matching files the linter should skip. When
20+
# omitted/null, the linter excludes no Go files. If assigned then only the
21+
# files that their relative path (with respect to the config file path) does not
22+
# match any of the patterns will be processed.
23+
#
24+
# Note: The patterns must assume a Unix-like path (i.e., separated with forward
25+
# slashes, `/`), even on Windows. This is to ensure a consistent behavior across
26+
# different platforms.
27+
#
28+
# Example:
29+
# exclude:
30+
# - ^internal/
31+
# - _autogenerated.go$
32+
exclude:
33+
- ^private/gen
34+
35+
# Default set of rules to enable. Possible values are:
36+
# - `basic`: enables basic rules which are: `pkg-doc`, `single-pkg-doc`, `start-with-name` and `deprecated`.
37+
# - `all`: all rules are enabled by default; the `disable` key can be used to disable specific rules.
38+
# - `none`: no rule is enabled by default; the `enable` key can be used to enable specific rules.
39+
default: none
40+
41+
# List of rules to enable *in addition to* the default set.
42+
#
43+
# See the linter docs for more on supported rules.
44+
#
45+
# Example:
46+
# - pkg-doc
47+
# - single-pkg-doc
48+
# - require-pkg-doc
49+
# - specific-file-pkg-doc
50+
# - start-with-name
51+
# - require-doc
52+
# - deprecated
53+
# - max-len
54+
# - no-unused-link
55+
enable:
56+
- pkg-doc
57+
- single-pkg-doc
58+
#- require-pkg-doc
59+
- specific-file-pkg-doc
60+
- start-with-name
61+
#- require-doc
62+
- deprecated
63+
#- max-len
64+
- no-unused-link
65+
66+
# List of rules to disable.
67+
#
68+
# Example:
69+
# disable:
70+
# - pkg-doc
71+
# - single-pkg-doc
72+
disable: null
73+
74+
# A map for setting individual rule options.
75+
#
76+
# All sub-keys are optional.
77+
options:
78+
# Maximum line length for godocs, not including the `// `, or `/*` or `*/`
79+
# tokens.
80+
max-len/length: 120
81+
82+
# Include test files when applying the `max-len` rule.
83+
max-len/include-tests: false
84+
85+
# Include test files when applying the `pkg-doc` rule.
86+
pkg-doc/include-tests: false
87+
88+
# Include test files when applying the `single-pkg-doc` rule.
89+
single-pkg-doc/include-tests: false
90+
91+
# Include test files when applying the `require-pkg-doc` rule.
92+
require-pkg-doc/include-tests: false
93+
94+
# Include test files when applying the `specific-file-pkg-doc` rule.
95+
specific-file-pkg-doc/include-tests: false
96+
97+
# The file pattern to indicate which file should contain the package-level godoc when
98+
# applying the `specific-file-pkg-doc` rule.
99+
#
100+
# Valid values are:
101+
#
102+
# - "doc": The godoc should be in a file named doc.go
103+
# - "package-name": The godoc should be in a file named after the package. For example, if a package
104+
# is named "foobar", the godoc should be in a file named "foobar.go".
105+
specific-file-pkg-doc/file-pattern: "package-name"
106+
107+
# Include test files when applying the `require-doc` rule.
108+
require-doc/include-tests: false
109+
110+
# Ignore exported (public) symbols when applying the `require-doc` rule.
111+
require-doc/ignore-exported: false
112+
113+
# Ignore unexported (private) symbols when applying the `require-doc` rule.
114+
require-doc/ignore-unexported: true
115+
116+
# Include test files when applying the `start-with-name` rule.
117+
start-with-name/include-tests: false
118+
119+
# Include unexported (private) symbols when applying the `start-with-name` rule.
120+
start-with-name/include-unexported: false
121+
122+
# Include test files when applying the `no-unused-link` rule.
123+
no-unused-link/include-tests: false

make/buf/all.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ include make/go/license_header.mk
7070
include make/go/bandeps.mk
7171
include make/go/bufprivateusage.mk
7272
include make/go/bufstyle.mk
73+
include make/go/godoclint.mk
7374
include make/go/buf.mk
7475

7576
installtest:: $(PROTOC) $(PROTOC_GEN_GO)

make/go/dep_bufstyle.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ $(call _assert_var,BUF_VERSION)
1010

1111
# Settable
1212
# https://github.com/bufbuild/bufstyle-go/releases
13-
BUFSTYLE_VERSION ?= v0.4.0
13+
BUFSTYLE_VERSION ?= v0.5.0
1414

1515
BUFSTYLE := $(CACHE_VERSIONS)/bufstyle/$(BUFSTYLE_VERSION)
1616
$(BUFSTYLE):

make/go/dep_godoclint.mk

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Managed by makego. DO NOT EDIT.
2+
3+
# Must be set
4+
$(call _assert_var,MAKEGO)
5+
$(call _conditional_include,$(MAKEGO)/base.mk)
6+
$(call _conditional_include,$(MAKEGO)/dep_buf.mk)
7+
$(call _assert_var,CACHE_VERSIONS)
8+
$(call _assert_var,CACHE_BIN)
9+
$(call _assert_var,BUF_VERSION)
10+
11+
# Settable
12+
#
13+
# Based off of dev branch.
14+
# https://github.com/bufbuild/godoc-lint/commits/dev
15+
GODOCLINT_VERSION ?= b4372dc9d4f721e956227cbcbd11947d81f246e2
16+
17+
GODOCLINT := $(CACHE_VERSIONS)/godoclint/$(GODOCLINT_VERSION)
18+
$(GODOCLINT):
19+
@rm -f $(CACHE_BIN)/godoclint
20+
$(eval GODOCLINT_TMP := $(shell mktemp -d))
21+
cd $(GODOCLINT_TMP); \
22+
git clone https://github.com/bufbuild/godoc-lint && \
23+
cd ./godoc-lint && \
24+
git checkout $(GODOCLINT_VERSION) && \
25+
GOBIN=$(CACHE_BIN) go install ./cmd/godoclint
26+
@rm -rf $(GODOCLINT_TMP)
27+
@rm -rf $(dir $(GODOCLINT))
28+
@mkdir -p $(dir $(GODOCLINT))
29+
@touch $(GODOCLINT)
30+
31+
dockerdeps:: $(GODOCLINT)

make/go/godoclint.mk

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Managed by makego. DO NOT EDIT.
2+
3+
# Must be set
4+
$(call _assert_var,MAKEGO)
5+
$(call _conditional_include,$(MAKEGO)/base.mk)
6+
$(call _conditional_include,$(MAKEGO)/go.mk)
7+
$(call _conditional_include,make/go/dep_godoclint.mk)
8+
# Must be set
9+
$(call _assert_var,GOPKGS)
10+
11+
.PHONY: godoclint
12+
godoclint: $(GODOCLINT)
13+
@echo godoclint GOPKGS
14+
@godoclint $(GOPKGS)
15+
16+
postlint:: godoclint

private/buf/bufctl/option.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ func WithCopyToInMemory() ControllerOption {
4444
}
4545
}
4646

47+
// FunctionOption is an option for a function in a Controller.
48+
//
4749
// TODO FUTURE: split up to per-function.
4850
type FunctionOption func(*functionOptions)
4951

private/buf/buflsp/config.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,14 @@ package buflsp
2222
//
2323
// Keep in sync with bufbuild/vscode-buf package.json.
2424
const (
25-
// The strategy for how to calculate the --against input for a breaking
26-
// check. This must be one of the following values:
25+
// ConfigBreakingStrategy is the strategy for how to calculate the --against input
26+
// for a breaking check. This must be one of the following values:
2727
//
2828
// - "git". Use a particular Git revision to find the against file.
29-
//
3029
// - "disk". Use the last-saved value on disk as the against file.
3130
ConfigBreakingStrategy = "buf.checks.breaking.againstStrategy"
32-
// The Git revision to use for calculating the --against input for a
33-
// breaking check when using the "git" strategy.
31+
// ConfigBreakingGitRef is the Git revision to use for calculating the --against input
32+
// for a breaking check when using the "git" strategy.
3433
ConfigBreakingGitRef = "buf.checks.breaking.againstGitRef"
3534
)
3635

private/buf/buflsp/jsonrpc_wrappers.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
// Package buflsp implements a language server for Protobuf.
16-
//
17-
// The main entry-point of this package is the Serve() function, which creates a new LSP server.
1815
package buflsp
1916

2017
import (

private/buf/buflsp/server.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
// Package buflsp implements a language server for Protobuf.
16-
//
17-
// The main entry-point of this package is the Serve() function, which creates a new LSP server.
1815
package buflsp
1916

2017
import (

private/buf/buflsp/symbol.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ func (s *symbol) FormatDocs(ctx context.Context) string {
257257
return tooltip.String()
258258
}
259259

260-
// GetSymbolInformat returns the protocol symbol information for the symbol.
260+
// GetSymbolInformation returns the protocol symbol information for the symbol.
261261
func (s *symbol) GetSymbolInformation() protocol.SymbolInformation {
262262
if s.ir.IsZero() {
263263
return protocol.SymbolInformation{}

0 commit comments

Comments
 (0)