-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Testable examples must have an output
comment
#3084
Comments
output
commentoutput
comment
At first glance it's a good idea. func Example_sameLine() { // nolint:testableexamples
panic("xxx")
}
// nolint:testableexamples
func Example_previousLine() {
panic("xxx")
} |
@maratori you must write nolint with the directive syntax. The comment syntax is now deprecated. From my memories, directives are excluded from the generated godoc. Due to a change of So the option The syntax of directives is: // nolint:foo // <-- malformed
//nolint :foo // <-- malformed
//nolint: foo // <-- malformed
//nolint:foo // <-- OK If you do that your IDE or go fmt will format the directive as a directive and it will not add extra space. Related to: |
@ldez you are right. Directives are excluded form godoc. //nolint:testableexamples
func Example_previousLine() {
panic("xxx")
}
func Example_sameLine() { //nolint:testableexamples
panic("xxx")
} Ok, then I'll create a linter. |
closed by #3170 |
Your feature request related to a problem? Please describe.
When writing testable examples, the following code is expected:
Or a lowercase
output
:However, when writing the following, without an
Output
comment:Then the test compiles correctly, but is not picked up by
go test
.We should add a rule which flags when an
output
comment is missing.Describe the solution you'd like.
Add a new rule which flags when a testable example - a test that has the test method prefix
Example
- does not contain a comment with anOutput:
Describe alternatives you've considered.
This may not be fit to come into golangci-lint per se, but into one of the other linters.
Additional context.
No response
The text was updated successfully, but these errors were encountered: