Skip to content

Commit ededae2

Browse files
committed
review
1 parent 49eddf5 commit ededae2

14 files changed

+53
-502
lines changed

.golangci.next.reference.yml

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,22 +1269,6 @@ linters:
12691269
min-complexity: 10
12701270

12711271
godoclint:
1272-
# List of regexp patterns matching files the linter should include. If assigned,
1273-
# then only the files whose relative path matches any of the patterns will be
1274-
# processed. Pattern should assume Unix-style paths ("/"-separated).
1275-
# Default: null (include all)
1276-
include:
1277-
- ^pkg/
1278-
- _foo.go$
1279-
1280-
# List of regexp patterns matching files the linter should skip. If assigned,
1281-
# then only the files whose relative path does not match any of the patterns will be
1282-
# processed. Pattern should assume Unix-style paths ("/"-separated).
1283-
# Default: null (exclude none)
1284-
exclude:
1285-
- ^internal/
1286-
- _autogenerated.go$
1287-
12881272
# List of rules to enable. See the linter docs for more details.
12891273
# Default:
12901274
# - pkg-doc
@@ -1320,29 +1304,11 @@ linters:
13201304
# Default: 77
13211305
length: 127
13221306

1323-
# Include test files when applying the `max-len` rule.
1324-
# Default: false
1325-
include-tests: true
1326-
13271307
pkg-doc:
13281308
# The start of a valid package godoc (e.g., "Package <NAME>...").
13291309
# Default: "Package"
13301310
start-with: PACKAGE
13311311

1332-
# Include test files when applying the `pkg-doc` rule.
1333-
# Default: false
1334-
include-tests: true
1335-
1336-
single-pkg-doc:
1337-
# Include test files when applying the `single-pkg-doc` rule.
1338-
# Default: false
1339-
include-tests: true
1340-
1341-
require-pkg-doc:
1342-
# Include test files when applying the `require-pkg-doc` rule.
1343-
# Default: false
1344-
include-tests: true
1345-
13461312
require-doc:
13471313
# Ignore exported (public) symbols when applying the `require-doc` rule.
13481314
# Default: false
@@ -1352,10 +1318,6 @@ linters:
13521318
# Default: true
13531319
ignore-unexported: false
13541320

1355-
# Include test files when applying the `require-doc` rule.
1356-
# Default: false
1357-
include-tests: true
1358-
13591321
start-with-name:
13601322
# Acceptable start pattern (regexp) for godocs when applying the
13611323
# `start-with-name` rule. The `%` placeholder is where the corresponding
@@ -1368,15 +1330,6 @@ linters:
13681330
# Default: false
13691331
include-unexported: true
13701332

1371-
# Include test files when applying the `start-with-name` rule.
1372-
# Default: false
1373-
include-tests: false
1374-
1375-
no-unused-link:
1376-
# Include test files when applying the `no-unused-link` rule.
1377-
# Default: false
1378-
include-tests: false
1379-
13801333
godot:
13811334
# Comments to be checked: `declarations`, `toplevel`, `noinline` or `all`.
13821335
# Default: declarations

go.sum

Lines changed: 0 additions & 6 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: 13 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,17 @@
477477
"-QF1012"
478478
]
479479
},
480+
"godoclint-rules": {
481+
"enum": [
482+
"pkg-doc",
483+
"single-pkg-doc",
484+
"require-pkg-doc",
485+
"start-with-name",
486+
"require-doc",
487+
"max-len",
488+
"no-unused-link"
489+
]
490+
},
480491
"gosec-rules": {
481492
"enum": [
482493
"G101",
@@ -1852,38 +1863,6 @@
18521863
"godoclintSettings": {
18531864
"type": "object",
18541865
"properties": {
1855-
"include": {
1856-
"default": null,
1857-
"description": "List of regexp patterns matching relative paths to files the linter should include. Paths are forward-slash separated (Unix-style).",
1858-
"oneOf": [
1859-
{
1860-
"type": "array",
1861-
"uniqueItems": true,
1862-
"items": {
1863-
"type": "string"
1864-
}
1865-
},
1866-
{
1867-
"type": "null"
1868-
}
1869-
]
1870-
},
1871-
"exclude": {
1872-
"default": null,
1873-
"description": "List of regexp patterns matching relative paths to files the linter should skip. Paths are forward-slash separated (Unix-style).",
1874-
"oneOf": [
1875-
{
1876-
"type": "array",
1877-
"uniqueItems": true,
1878-
"items": {
1879-
"type": "string"
1880-
}
1881-
},
1882-
{
1883-
"type": "null"
1884-
}
1885-
]
1886-
},
18871866
"enable": {
18881867
"default": null,
18891868
"description": "List of rules to enable.",
@@ -1892,16 +1871,7 @@
18921871
"type": "array",
18931872
"uniqueItems": true,
18941873
"items": {
1895-
"type": "string",
1896-
"enum": [
1897-
"pkg-doc",
1898-
"single-pkg-doc",
1899-
"require-pkg-doc",
1900-
"start-with-name",
1901-
"require-doc",
1902-
"max-len",
1903-
"no-unused-link"
1904-
]
1874+
"$ref": "#/definitions/godoclint-rules"
19051875
}
19061876
},
19071877
{
@@ -1917,16 +1887,7 @@
19171887
"type": "array",
19181888
"uniqueItems": true,
19191889
"items": {
1920-
"type": "string",
1921-
"enum": [
1922-
"pkg-doc",
1923-
"single-pkg-doc",
1924-
"require-pkg-doc",
1925-
"start-with-name",
1926-
"require-doc",
1927-
"max-len",
1928-
"no-unused-link"
1929-
]
1890+
"$ref": "#/definitions/godoclint-rules"
19301891
}
19311892
},
19321893
{
@@ -1945,11 +1906,6 @@
19451906
"type": "integer",
19461907
"description": "Maximum line length for godocs, not including the `// `, or `/*` or `*/` tokens.",
19471908
"default": 77
1948-
},
1949-
"include-tests": {
1950-
"type": "boolean",
1951-
"description": "Include test files when applying the `max-len` rule.",
1952-
"default": false
19531909
}
19541910
}
19551911
},
@@ -1960,42 +1916,12 @@
19601916
"type": "string",
19611917
"description": "The start of a valid package godoc (e.g., \"Package <NAME>...\").",
19621918
"default": "Package"
1963-
},
1964-
"include-tests": {
1965-
"type": "boolean",
1966-
"description": "Include test files when applying the `pkg-doc` rule.",
1967-
"default": false
1968-
}
1969-
}
1970-
},
1971-
"single-pkg-doc": {
1972-
"type": "object",
1973-
"properties": {
1974-
"include-tests": {
1975-
"type": "boolean",
1976-
"description": "Include test files when applying the `single-pkg-doc` rule.",
1977-
"default": false
1978-
}
1979-
}
1980-
},
1981-
"require-pkg-doc": {
1982-
"type": "object",
1983-
"properties": {
1984-
"include-tests": {
1985-
"type": "boolean",
1986-
"description": "Include test files when applying the `require-pkg-doc` rule.",
1987-
"default": false
19881919
}
19891920
}
19901921
},
19911922
"require-doc": {
19921923
"type": "object",
19931924
"properties": {
1994-
"include-tests": {
1995-
"type": "boolean",
1996-
"description": "Include test files when applying the `require-doc` rule.",
1997-
"default": false
1998-
},
19991925
"ignore-exported": {
20001926
"type": "boolean",
20011927
"description": "Ignore exported (public) symbols when applying the `require-doc` rule.",
@@ -2011,11 +1937,6 @@
20111937
"start-with-name": {
20121938
"type": "object",
20131939
"properties": {
2014-
"include-tests": {
2015-
"type": "boolean",
2016-
"description": "Include test files when applying the `start-with-name` rule.",
2017-
"default": false
2018-
},
20191940
"include-unexported": {
20201941
"type": "boolean",
20211942
"description": "Include unexported symbols when applying the `start-with-name` rule.",
@@ -2027,16 +1948,6 @@
20271948
"default": "((A|a|An|an|THE|The|the) )?%"
20281949
}
20291950
}
2030-
},
2031-
"no-unused-link": {
2032-
"type": "object",
2033-
"properties": {
2034-
"include-tests": {
2035-
"type": "boolean",
2036-
"description": "Include test files when applying the `no-unused-link` rule.",
2037-
"default": false
2038-
}
2039-
}
20401951
}
20411952
}
20421953
}

pkg/config/linters_settings.go

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

524524
type GodoclintSettings struct {
525-
Include []string `mapstructure:"include"`
526-
Exclude []string `mapstructure:"exclude"`
527525
Enable []string `mapstructure:"enable"`
528526
Disable []string `mapstructure:"disable"`
529527
Options struct {
530528
MaxLen struct {
531-
Length *uint `mapstructure:"length"`
532-
IncludeTests *bool `mapstructure:"include-tests"`
529+
Length *uint `mapstructure:"length"`
533530
} `mapstructure:"max-len"`
534531
PkgDoc struct {
535-
StartWith *string `mapstructure:"start-with"`
536-
IncludeTests *bool `mapstructure:"include-tests"`
532+
StartWith *string `mapstructure:"start-with"`
537533
} `mapstructure:"pkg-doc"`
538-
SinglePkgDoc struct {
539-
IncludeTests *bool `mapstructure:"include-tests"`
540-
}
541-
RequirePkgDoc struct {
542-
IncludeTests *bool `mapstructure:"include-tests"`
543-
} `mapstructure:"require-pkg-doc"`
544534
RequireDoc struct {
545535
IgnoreExported *bool `mapstructure:"ignore-exported"`
546536
IgnoreUnexported *bool `mapstructure:"ignore-unexported"`
547-
IncludeTests *bool `mapstructure:"include-tests"`
548537
} `mapstructure:"require-doc"`
549538
StartWithName struct {
550539
Pattern *string `mapstructure:"pattern"`
551540
IncludeUnexported *bool `mapstructure:"include-unexported"`
552-
IncludeTests *bool `mapstructure:"include-tests"`
553541
} `mapstructure:"start-with-name"`
554-
NoUnusedLink struct {
555-
IncludeTests *bool `mapstructure:"include-tests"`
556-
} `mapstructure:"no-unused-link"`
557542
} `mapstructure:"options"`
558543
}
559544

pkg/golinters/godoclint/godoclint.go

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,41 @@ import (
99
)
1010

1111
func New(settings *config.GodoclintSettings) *goanalysis.Linter {
12-
pcfg := glconfig.PlainConfig{
13-
Include: settings.Include,
14-
Exclude: settings.Exclude,
15-
Enable: settings.Enable,
16-
Disable: settings.Disable,
17-
Options: &glconfig.PlainRuleOptions{
18-
MaxLenLength: settings.Options.MaxLen.Length,
19-
MaxLenIncludeTests: settings.Options.MaxLen.IncludeTests,
20-
PkgDocStartWith: settings.Options.PkgDoc.StartWith,
21-
PkgDocIncludeTests: settings.Options.PkgDoc.IncludeTests,
22-
SinglePkgDocIncludeTests: settings.Options.SinglePkgDoc.IncludeTests,
23-
RequirePkgDocIncludeTests: settings.Options.RequirePkgDoc.IncludeTests,
24-
RequireDocIncludeTests: settings.Options.RequireDoc.IncludeTests,
25-
RequireDocIgnoreExported: settings.Options.RequireDoc.IgnoreExported,
26-
RequireDocIgnoreUnexported: settings.Options.RequireDoc.IgnoreUnexported,
27-
StartWithNamePattern: settings.Options.StartWithName.Pattern,
28-
StartWithNameIncludeTests: settings.Options.StartWithName.IncludeTests,
29-
StartWithNameIncludeUnexported: settings.Options.StartWithName.IncludeUnexported,
30-
NoUnusedLinkIncludeTests: settings.Options.NoUnusedLink.IncludeTests,
31-
},
12+
var pcfg glconfig.PlainConfig
13+
14+
if settings != nil {
15+
// The following options are explicitly ignored: they must be handled globally with exclusions or nolint directives.
16+
// - Include
17+
// - Exclude
18+
19+
// The following options are explicitly ignored: these options cannot work as expected because the global configuration about tests.
20+
// - Options.MaxLenIncludeTests
21+
// - Options.PkgDocIncludeTests
22+
// - Options.SinglePkgDocIncludeTests
23+
// - Options.RequirePkgDocIncludeTests
24+
// - Options.RequireDocIncludeTests
25+
// - Options.StartWithNameIncludeTests
26+
// - Options.NoUnusedLinkIncludeTests
27+
28+
pcfg = glconfig.PlainConfig{
29+
Enable: settings.Enable,
30+
Disable: settings.Disable,
31+
Options: &glconfig.PlainRuleOptions{
32+
MaxLenLength: settings.Options.MaxLen.Length,
33+
MaxLenIncludeTests: pointer(true),
34+
PkgDocStartWith: settings.Options.PkgDoc.StartWith,
35+
PkgDocIncludeTests: pointer(false),
36+
SinglePkgDocIncludeTests: pointer(true),
37+
RequirePkgDocIncludeTests: pointer(false),
38+
RequireDocIncludeTests: pointer(true),
39+
RequireDocIgnoreExported: settings.Options.RequireDoc.IgnoreExported,
40+
RequireDocIgnoreUnexported: settings.Options.RequireDoc.IgnoreUnexported,
41+
StartWithNamePattern: settings.Options.StartWithName.Pattern,
42+
StartWithNameIncludeTests: pointer(true),
43+
StartWithNameIncludeUnexported: settings.Options.StartWithName.IncludeUnexported,
44+
NoUnusedLinkIncludeTests: pointer(true),
45+
},
46+
}
3247
}
3348

3449
composition := glcompose.Compose(glcompose.CompositionConfig{
@@ -37,5 +52,7 @@ func New(settings *config.GodoclintSettings) *goanalysis.Linter {
3752

3853
return goanalysis.
3954
NewLinterFromAnalyzer(composition.Analyzer.GetAnalyzer()).
40-
WithLoadMode(goanalysis.LoadModeTypesInfo)
55+
WithLoadMode(goanalysis.LoadModeSyntax)
4156
}
57+
58+
func pointer[T any](v T) *T { return &v }

0 commit comments

Comments
 (0)