|
| 1 | +//golangcitest:args -Egodoclint |
| 2 | +//golangcitest:config_path testdata/godoclint.yml |
| 3 | + |
| 4 | +// Asserting rule "pkg-doc" |
| 5 | + |
| 6 | +// bad godoc // want `package godoc should start with "PACKAGE testdata_test "` |
| 7 | +package testdata_test |
| 8 | + |
| 9 | +// This is a special stdlib import because the package itself has issues that |
| 10 | +// godoclint can, but must not, detect. |
| 11 | +import "go/ast" |
| 12 | + |
| 13 | +// Asserting rule "start-with-name" |
| 14 | + |
| 15 | +// bad godoc // want `godoc should start with symbol name \(pattern "GODOC %"\)` |
| 16 | +type FooType struct{} |
| 17 | + |
| 18 | +// bad godoc // want `godoc should start with symbol name \(pattern "GODOC %"\)` |
| 19 | +type FooAlias = ast.Comment |
| 20 | + |
| 21 | +// bad godoc // want `godoc should start with symbol name \(pattern "GODOC %"\)` |
| 22 | +const FooConst = 1 |
| 23 | + |
| 24 | +// bad godoc // want `godoc should start with symbol name \(pattern "GODOC %"\)` |
| 25 | +var FooVar = 1 |
| 26 | + |
| 27 | +// bad godoc // want `godoc should start with symbol name \(pattern "GODOC %"\)` |
| 28 | +func FooFunc() {} |
| 29 | + |
| 30 | +// bad godoc // want `godoc should start with symbol name \(pattern "GODOC %"\)` |
| 31 | +func (FooType) FooFunc() {} |
| 32 | + |
| 33 | +// bad godoc // want `godoc should start with symbol name \(pattern "GODOC %"\)` |
| 34 | +type fooType struct{} |
| 35 | + |
| 36 | +// bad godoc // want `godoc should start with symbol name \(pattern "GODOC %"\)` |
| 37 | +type fooAlias = ast.Comment |
| 38 | + |
| 39 | +// bad godoc // want `godoc should start with symbol name \(pattern "GODOC %"\)` |
| 40 | +const fooConst = 1 |
| 41 | + |
| 42 | +// bad godoc // want `godoc should start with symbol name \(pattern "GODOC %"\)` |
| 43 | +var fooVar = 1 |
| 44 | + |
| 45 | +// bad godoc // want `godoc should start with symbol name \(pattern "GODOC %"\)` |
| 46 | +func fooFunc() {} |
| 47 | + |
| 48 | +// bad godoc // want `godoc should start with symbol name \(pattern "GODOC %"\)` |
| 49 | +func (FooType) fooFunc() {} |
| 50 | + |
| 51 | +// Asserting rule "require-doc" |
| 52 | + |
| 53 | +// The //foo:bar directives mark the trailing comment as a directive so they're |
| 54 | +// not parsed as a normal trailing comment group. |
| 55 | + |
| 56 | +type BarType struct{} //foo:bar // want `symbol should have a godoc \(BarType\)` |
| 57 | + |
| 58 | +type BarAlias = ast.Comment //foo:bar // want `symbol should have a godoc \(BarAlias\)` |
| 59 | + |
| 60 | +const BarConst = 1 //foo:bar // want `symbol should have a godoc \(BarConst\)` |
| 61 | + |
| 62 | +var BarVar = 1 //foo:bar // want `symbol should have a godoc \(BarVar\)` |
| 63 | + |
| 64 | +func BarFunc() {} //foo:bar // want `symbol should have a godoc \(BarFunc\)` |
| 65 | + |
| 66 | +func (BarType) BarFunc() {} //foo:bar // want `symbol should have a godoc \(BarFunc\)` |
| 67 | + |
| 68 | +type barType struct{} //foo:bar // want `symbol should have a godoc \(barType\)` |
| 69 | + |
| 70 | +type barAlias = ast.Comment //foo:bar // want `symbol should have a godoc \(barAlias\)` |
| 71 | + |
| 72 | +const barConst = 1 //foo:bar // want `symbol should have a godoc \(barConst\)` |
| 73 | + |
| 74 | +var barVar = 1 //foo:bar // want `symbol should have a godoc \(barVar\)` |
| 75 | + |
| 76 | +func barFunc() {} //foo:bar // want `symbol should have a godoc \(barFunc\)` |
| 77 | + |
| 78 | +func (BarType) barFunc() {} //foo:bar // want `symbol should have a godoc \(barFunc\)` |
| 79 | + |
| 80 | +// Asserting rule "no-unused-link" |
| 81 | + |
| 82 | +// GODOC constWithUnusedLink point to [used] and unused links. // want `godoc has unused link \(unused\)` |
| 83 | +// |
| 84 | +// [used]: https://example.com |
| 85 | +// |
| 86 | +// [unused]: https://example.com |
| 87 | +const constWithUnusedLink = 1 |
| 88 | + |
| 89 | +// Asserting rule "max-len" |
| 90 | + |
| 91 | +// GODOC constWithTooLongGodoc has a very long godoc that exceeds the maximum allowed length for godoc comments in this test setup. // want `godoc exceeds max length \(177 > 127\)` |
| 92 | +const constWithTooLongGodoc = 1 |
0 commit comments