mirror of
https://github.com/mgechev/revive.git
synced 2025-11-23 22:04:49 +02:00
makes exported rule behave as golint (#1051)
Co-authored-by: chavacava <salvador.cavadini@gmail.com>
This commit is contained in:
@@ -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
|
// if comment starts with name of type and has some text after - it's ok
|
||||||
expectedPrefix := t.Name.Name+" "
|
expectedPrefix := t.Name.Name + " "
|
||||||
if strings.HasPrefix(s, expectedPrefix){
|
if strings.HasPrefix(s, expectedPrefix) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.onFailure(lint.Failure{
|
w.onFailure(lint.Failure{
|
||||||
@@ -244,7 +244,7 @@ func (w *lintExported) lintValueSpecDoc(vs *ast.ValueSpec, gd *ast.GenDecl, genD
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if vs.Doc == nil && vs.Comment == nil && gd.Doc == nil {
|
if vs.Doc == nil && gd.Doc == nil {
|
||||||
if genDeclMissingComments[gd] {
|
if genDeclMissingComments[gd] {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -348,7 +348,7 @@ func (w *lintExported) doCheckPublicInterface(typeName string, iface *ast.Interf
|
|||||||
|
|
||||||
func (w *lintExported) lintInterfaceMethod(typeName string, m *ast.Field) {
|
func (w *lintExported) lintInterfaceMethod(typeName string, m *ast.Field) {
|
||||||
if len(m.Names) == 0 {
|
if len(m.Names) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !ast.IsExported(m.Names[0].Name) {
|
if !ast.IsExported(m.Names[0].Name) {
|
||||||
return
|
return
|
||||||
|
|||||||
6
testdata/golint/const-block.go
vendored
6
testdata/golint/const-block.go
vendored
@@ -4,16 +4,16 @@
|
|||||||
package foo
|
package foo
|
||||||
|
|
||||||
const (
|
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 ..."/
|
// MATCH /comment on exported const InlineWhatever should be of the form "InlineWhatever ..."/
|
||||||
InlineWhatever = "blah"
|
InlineWhatever = "blah"
|
||||||
|
|
||||||
Whatsit = "missing_comment"
|
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,
|
// 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.
|
// but always complain about malformed comments.
|
||||||
|
|
||||||
WhosYourDaddy = "another_missing_one"
|
WhosYourDaddy = "another_missing_one"
|
||||||
|
|||||||
Reference in New Issue
Block a user