-
Notifications
You must be signed in to change notification settings - Fork 305
exported: correctly report deprecation-only comments #1295
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
Conversation
// e.g. //go:embed foo.txt a directive comment, not a text comment | ||
// e.g. //nolint:whatever is a directive comment, not a text comment | ||
func hasTextComment(comment *ast.CommentGroup) bool { | ||
// e.g. // Deprecated: this is a deprecation comment | ||
func hasDocComment(comment *ast.CommentGroup) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expanded the logic of this function to check that the comment contains a non-empty text comment and is not solely a deprecation comment. I renamed it to reflect this change. I can adjust the name if you have a better suggestion.
…ormat (in that order)
Hi @semihbkgr thanks for the PR! I've added a test case to the PR. The case is that of a function with a deprecation comment line followed by a wrong comment line ( |
Hi @chavacava I assumed that everything following the |
The official doc on deprecation comments says:
// Package rc4 implements the RC4 stream cipher.
//
// Deprecated: RC4 is cryptographically broken and should not be used
// except for compatibility with legacy systems.
//
// This package is frozen and no new functionality will be added.
package rc4 Let's assume that the deprecation "section" is always after the "documentation" section. |
So we can assume that the doc comment comes before the deprecation comment - this isn’t a strict rule, but it’s a commonly followed convention. // Deprecated: this is deprecated, use min instead -> deprecation comment
// -> end of paragraph
// Min returns a if a <= b, b otherwise. -> doc comment
func Min(a, b int) int { |
Let's keep it simple and stick to the convention (comment + deprecation) |
…standard ordering convention
Thank you guys for working on this. I was out with family, I only review it now. |
Closes #1231
Fixed the exported rule to correctly handle and exclude deprecation-only comments.
Previously, when only a deprecation comment was present, it incorrectly reported:
comment on exported type ... should be of the form
;now it reports:
exported type ... should have comment or be unexported.