Skip to content

Commit 5053586

Browse files
committed
fix: upgrade godoclint v0.8.0
The version of godoclint has removed extra configuration parameters, and introduced a new `default` parameter to control the default set of enabled rules. Signed-off-by: Babak K. Shandiz <[email protected]>
1 parent f9ff8b2 commit 5053586

File tree

10 files changed

+60
-82
lines changed

10 files changed

+60
-82
lines changed

.golangci.next.reference.yml

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,11 +1269,12 @@ linters:
12691269
min-complexity: 10
12701270

12711271
godoclint:
1272-
# List of rules to enable. See the linter docs for more details.
1273-
# Default:
1274-
# - pkg-doc
1275-
# - single-pkg-doc
1276-
# - start-with-name
1272+
# Default set of rules to enable. Possible values are: `basic`, `all` or `none`.
1273+
# Default: basic (enables `pkg-doc`, `single-pkg-doc`, and `start-with-name`)
1274+
default: all
1275+
1276+
# List of rules to enable in addition to default set. See the linter docs for more details.
1277+
# Default: null
12771278
enable:
12781279
# Check proper package-level godoc, if any
12791280
- pkg-doc
@@ -1290,12 +1291,16 @@ linters:
12901291
# Assert no unused link in godocs
12911292
- no-unused-link
12921293

1293-
# List of rules to disable, useful when using the default rules.
1294+
# List of rules to disable.
12941295
# Default: null
12951296
disable:
12961297
- pkg-doc
12971298
- single-pkg-doc
1299+
- require-pkg-doc
12981300
- start-with-name
1301+
- require-doc
1302+
- max-len
1303+
- no-unused-link
12991304

13001305
# A map for fine tuning individual rules. All sub-keys are optional.
13011306
options:
@@ -1304,11 +1309,6 @@ linters:
13041309
# Default: 77
13051310
length: 127
13061311

1307-
pkg-doc:
1308-
# The start of a valid package godoc (e.g., "Package <NAME>...").
1309-
# Default: "Package"
1310-
start-with: PACKAGE
1311-
13121312
require-doc:
13131313
# Ignore exported (public) symbols when applying the `require-doc` rule.
13141314
# Default: false
@@ -1319,13 +1319,6 @@ linters:
13191319
ignore-unexported: false
13201320

13211321
start-with-name:
1322-
# Acceptable start pattern (regexp) for godocs when applying the
1323-
# `start-with-name` rule. The `%` placeholder is where the corresponding
1324-
# symbol name should appear. An omitted placeholder means the symbol
1325-
# name should appear at the end of the pattern.
1326-
# Default: "((A|a|An|an|THE|The|the) )?%"
1327-
pattern: "%"
1328-
13291322
# Include unexported symbols when applying the `start-with-name` rule.
13301323
# Default: false
13311324
include-unexported: true

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ require (
4545
github.com/go-critic/go-critic v0.13.0
4646
github.com/go-viper/mapstructure/v2 v2.4.0
4747
github.com/go-xmlfmt/xmlfmt v1.1.3
48-
github.com/godoc-lint/godoc-lint v0.7.0
48+
github.com/godoc-lint/godoc-lint v0.8.0
4949
github.com/gofrs/flock v0.12.1
5050
github.com/golangci/asciicheck v0.5.0
5151
github.com/golangci/dupl v0.0.0-20250308024227-f665c8d69b32

go.sum

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jsonschema/golangci.next.jsonschema.json

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1863,9 +1863,15 @@
18631863
"godoclintSettings": {
18641864
"type": "object",
18651865
"properties": {
1866+
"default": {
1867+
"type": "string",
1868+
"enum": ["all", "basic", "none"],
1869+
"default": "basic",
1870+
"description": "Default set of rules to enable."
1871+
},
18661872
"enable": {
18671873
"default": null,
1868-
"description": "List of rules to enable.",
1874+
"description": "List of rules to enable in addition to the default set.",
18691875
"oneOf": [
18701876
{
18711877
"type": "array",
@@ -1909,16 +1915,6 @@
19091915
}
19101916
}
19111917
},
1912-
"pkg-doc": {
1913-
"type": "object",
1914-
"properties": {
1915-
"start-with": {
1916-
"type": "string",
1917-
"description": "The start of a valid package godoc (e.g., \"Package <NAME>...\").",
1918-
"default": "Package"
1919-
}
1920-
}
1921-
},
19221918
"require-doc": {
19231919
"type": "object",
19241920
"properties": {
@@ -1941,11 +1937,6 @@
19411937
"type": "boolean",
19421938
"description": "Include unexported symbols when applying the `start-with-name` rule.",
19431939
"default": false
1944-
},
1945-
"pattern": {
1946-
"type": "string",
1947-
"description": "Acceptable start pattern (regexp) for godoc starte when applying the `start-with-name` rule. The `%` placeholder is where the corresponding symbol name should should appear. An omitted placeholder means the symbol name should appear at the end of the pattern.",
1948-
"default": "((A|a|An|an|THE|The|the) )?%"
19491940
}
19501941
}
19511942
}

pkg/config/linters_settings.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -522,22 +522,19 @@ type GoCycloSettings struct {
522522
}
523523

524524
type GodoclintSettings struct {
525+
Default *string `mapstructure:"default"`
525526
Enable []string `mapstructure:"enable"`
526527
Disable []string `mapstructure:"disable"`
527528
Options struct {
528529
MaxLen struct {
529530
Length *uint `mapstructure:"length"`
530531
} `mapstructure:"max-len"`
531-
PkgDoc struct {
532-
StartWith *string `mapstructure:"start-with"`
533-
} `mapstructure:"pkg-doc"`
534532
RequireDoc struct {
535533
IgnoreExported *bool `mapstructure:"ignore-exported"`
536534
IgnoreUnexported *bool `mapstructure:"ignore-unexported"`
537535
} `mapstructure:"require-doc"`
538536
StartWithName struct {
539-
Pattern *string `mapstructure:"pattern"`
540-
IncludeUnexported *bool `mapstructure:"include-unexported"`
537+
IncludeUnexported *bool `mapstructure:"include-unexported"`
541538
} `mapstructure:"start-with-name"`
542539
} `mapstructure:"options"`
543540
}

pkg/golinters/godoclint/godoclint.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,18 @@ func New(settings *config.GodoclintSettings) *goanalysis.Linter {
2626
// - Options.NoUnusedLinkIncludeTests
2727

2828
pcfg = glconfig.PlainConfig{
29+
Default: settings.Default,
2930
Enable: settings.Enable,
3031
Disable: settings.Disable,
3132
Options: &glconfig.PlainRuleOptions{
3233
MaxLenLength: settings.Options.MaxLen.Length,
3334
MaxLenIncludeTests: pointer(true),
34-
PkgDocStartWith: settings.Options.PkgDoc.StartWith,
3535
PkgDocIncludeTests: pointer(false),
3636
SinglePkgDocIncludeTests: pointer(true),
3737
RequirePkgDocIncludeTests: pointer(false),
3838
RequireDocIncludeTests: pointer(true),
3939
RequireDocIgnoreExported: settings.Options.RequireDoc.IgnoreExported,
4040
RequireDocIgnoreUnexported: settings.Options.RequireDoc.IgnoreUnexported,
41-
StartWithNamePattern: settings.Options.StartWithName.Pattern,
4241
StartWithNameIncludeTests: pointer(false),
4342
StartWithNameIncludeUnexported: settings.Options.StartWithName.IncludeUnexported,
4443
NoUnusedLinkIncludeTests: pointer(true),

pkg/golinters/godoclint/testdata/godoclint.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ version: "2"
33
linters:
44
settings:
55
godoclint:
6+
default: none
67
enable:
78
- pkg-doc
89
- require-pkg-doc
@@ -11,10 +12,7 @@ linters:
1112
- no-unused-link
1213
- max-len
1314
options:
14-
pkg-doc:
15-
start-with: PACKAGE
1615
start-with-name:
17-
pattern: "GODOC %"
1816
include-unexported: true
1917
require-doc:
2018
ignore-exported: false

pkg/golinters/godoclint/testdata/godoclint_full_fail_most_rules.go renamed to pkg/golinters/godoclint/testdata/godoclint_full_fail.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
// Asserting rule "pkg-doc"
55

6-
// bad godoc // want `package godoc should start with "PACKAGE testdata "`
6+
// bad godoc // want `package godoc should start with "Package testdata "`
77
package testdata
88

99
// This is a special stdlib import because the package itself has issues that
@@ -79,7 +79,7 @@ func (BarType) barFunc() {} //foo:bar // want `symbol should have a godoc \("bar
7979

8080
// Asserting rule "no-unused-link"
8181

82-
// GODOC constWithUnusedLink point to [used] and unused links. // want `godoc has unused link \("unused"\)`
82+
// constWithUnusedLink point to [used] and unused links. // want `godoc has unused link \("unused"\)`
8383
//
8484
// [used]: https://example.com
8585
//
@@ -88,5 +88,5 @@ const constWithUnusedLink = 1
8888

8989
// Asserting rule "max-len"
9090

91-
// GODOC constWithTooLongGodoc has a very long godoc that exceeds the maximum allowed length for godoc comments in this test setup. // want `godoc line is too long \(175 > 127\)`
91+
// constWithTooLongGodoc has a very long godoc that exceeds the maximum allowed length for godoc comments in this test setup. // want `godoc line is too long \(169 > 127\)`
9292
const constWithTooLongGodoc = 1

pkg/golinters/godoclint/testdata/godoclint_full_pass.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
// Asserting rule "pkg-doc" and "require-pkg-doc" since the package has a godoc.
66

7-
// PACKAGE testdata
7+
// Package testdata
88
package testdata
99

1010
// This is a special stdlib import because the package itself has issues that
@@ -13,50 +13,50 @@ import "go/ast"
1313

1414
// Asserting rule "start-with-name" and "require-doc" (since all have godocs)
1515

16-
// GODOC FooType is...
16+
// FooType is...
1717
type FooType struct{}
1818

19-
// GODOC FooAlias is...
19+
// FooAlias is...
2020
type FooAlias = ast.Comment
2121

22-
// GODOC FooConst is...
22+
// FooConst is...
2323
const FooConst = 1
2424

25-
// GODOC FooVar is...
25+
// FooVar is...
2626
var FooVar = 1
2727

28-
// GODOC FooFunc is...
28+
// FooFunc is...
2929
func FooFunc() {}
3030

31-
// GODOC FooFunc is...
31+
// FooFunc is...
3232
func (FooType) FooFunc() {}
3333

34-
// GODOC fooType is...
34+
// fooType is...
3535
type fooType struct{}
3636

37-
// GODOC fooAlias is...
37+
// fooAlias is...
3838
type fooAlias = ast.Comment
3939

40-
// GODOC fooConst is...
40+
// fooConst is...
4141
const fooConst = 1
4242

43-
// GODOC fooVar is...
43+
// fooVar is...
4444
var fooVar = 1
4545

46-
// GODOC fooFunc is...
46+
// fooFunc is...
4747
func fooFunc() {}
4848

49-
// GODOC fooFunc is...
49+
// fooFunc is...
5050
func (FooType) fooFunc() {}
5151

5252
// Asserting rule "no-unused-link"
5353

54-
// GODOC constWithUnusedLink point to a [used] link and has no unused one.
54+
// constWithUnusedLink point to a [used] link and has no unused one.
5555
//
5656
// [used]: https://example.com
5757
const constWithUnusedLink = 1
5858

5959
// Asserting rule "max-len"
6060

61-
// GODOC constWithTooLongGodoc has a very long godoc that does not exceed the maximum allowed length for godoc comments.
61+
// constWithTooLongGodoc has a very long godoc that does not exceed the maximum allowed length for godoc comments.
6262
const constWithTooLongGodoc = 1

pkg/golinters/godoclint/testdata/godoclint_full_pass_test.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,61 +2,61 @@
22
//golangcitest:config_path testdata/godoclint.yml
33
//golangcitest:expected_exitcode 0
44

5-
// Asserting rule "pkg-doc"
5+
// Asserting rule "pkg-doc" and "require-pkg-doc" since the package has a godoc.
66

7-
// PACKAGE testdata
7+
// Package testdata
88
package testdata
99

1010
// This is a special stdlib import because the package itself has issues that
1111
// godoclint can, but must not, detect.
1212
import "go/ast"
1313

14-
// Asserting rule "start-with-name" (also covering "require-doc" since all have godocs)
14+
// Asserting rule "start-with-name" and "require-doc" (since all have godocs)
1515

16-
// GODOC FooType is...
16+
// FooType is...
1717
type FooType struct{}
1818

19-
// GODOC FooAlias is...
19+
// FooAlias is...
2020
type FooAlias = ast.Comment
2121

22-
// GODOC FooConst is...
22+
// FooConst is...
2323
const FooConst = 1
2424

25-
// GODOC FooVar is...
25+
// FooVar is...
2626
var FooVar = 1
2727

28-
// GODOC FooFunc is...
28+
// FooFunc is...
2929
func FooFunc() {}
3030

31-
// GODOC FooFunc is...
31+
// FooFunc is...
3232
func (FooType) FooFunc() {}
3333

34-
// GODOC fooType is...
34+
// fooType is...
3535
type fooType struct{}
3636

37-
// GODOC fooAlias is...
37+
// fooAlias is...
3838
type fooAlias = ast.Comment
3939

40-
// GODOC fooConst is...
40+
// fooConst is...
4141
const fooConst = 1
4242

43-
// GODOC fooVar is...
43+
// fooVar is...
4444
var fooVar = 1
4545

46-
// GODOC fooFunc is...
46+
// fooFunc is...
4747
func fooFunc() {}
4848

49-
// GODOC fooFunc is...
49+
// fooFunc is...
5050
func (FooType) fooFunc() {}
5151

5252
// Asserting rule "no-unused-link"
5353

54-
// GODOC constWithUnusedLink point to a [used] link and has no unused one.
54+
// constWithUnusedLink point to a [used] link and has no unused one.
5555
//
5656
// [used]: https://example.com
5757
const constWithUnusedLink = 1
5858

5959
// Asserting rule "max-len"
6060

61-
// GODOC constWithTooLongGodoc has a very long godoc that does not exceed the maximum allowed length for godoc comments.
61+
// constWithTooLongGodoc has a very long godoc that does not exceed the maximum allowed length for godoc comments.
6262
const constWithTooLongGodoc = 1

0 commit comments

Comments
 (0)