1
0
mirror of https://github.com/mgechev/revive.git synced 2025-03-17 20:57:58 +02:00

makes exported rule behave as golint (#1051)

Co-authored-by: chavacava <salvador.cavadini@gmail.com>
This commit is contained in:
chavacava 2024-09-29 22:50:49 +02:00 committed by GitHub
parent fa37c00bdf
commit 798ce21849
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 7 deletions

View File

@ -204,8 +204,8 @@ func (w *lintExported) lintTypeDoc(t *ast.TypeSpec, doc *ast.CommentGroup) {
}
}
// if comment starts with name of type and has some text after - it's ok
expectedPrefix := t.Name.Name+" "
if strings.HasPrefix(s, expectedPrefix){
expectedPrefix := t.Name.Name + " "
if strings.HasPrefix(s, expectedPrefix) {
return
}
w.onFailure(lint.Failure{
@ -244,7 +244,7 @@ func (w *lintExported) lintValueSpecDoc(vs *ast.ValueSpec, gd *ast.GenDecl, genD
return
}
if vs.Doc == nil && vs.Comment == nil && gd.Doc == nil {
if vs.Doc == nil && gd.Doc == nil {
if genDeclMissingComments[gd] {
return
}
@ -348,7 +348,7 @@ func (w *lintExported) doCheckPublicInterface(typeName string, iface *ast.Interf
func (w *lintExported) lintInterfaceMethod(typeName string, m *ast.Field) {
if len(m.Names) == 0 {
return
return
}
if !ast.IsExported(m.Names[0].Name) {
return

View File

@ -4,16 +4,16 @@
package foo
const (
InlineComment = "ShouldBeOK" // InlineComment is a valid comment
InlineComment = "ShouldBeOK" // InlineComment is not a valid documentation
// MATCH:7 /exported const InlineComment should have comment (or a comment on this block) or be unexported/
// Prefix for something.
// MATCH /comment on exported const InlineWhatever should be of the form "InlineWhatever ..."/
InlineWhatever = "blah"
Whatsit = "missing_comment"
// MATCH:13 /exported const Whatsit should have comment (or a comment on this block) or be unexported/
// We should only warn once per block for missing comments,
// thus do not warn on:13 /exported const Whatsit should have comment (or a comment on this block) or be unexported/
// but always complain about malformed comments.
WhosYourDaddy = "another_missing_one"