Skip to content

Commit 798ce21

Browse files
chavacavachavacava
andauthored
makes exported rule behave as golint (#1051)
Co-authored-by: chavacava <[email protected]>
1 parent fa37c00 commit 798ce21

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

rule/exported.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@ func (w *lintExported) lintTypeDoc(t *ast.TypeSpec, doc *ast.CommentGroup) {
204204
}
205205
}
206206
// if comment starts with name of type and has some text after - it's ok
207-
expectedPrefix := t.Name.Name+" "
208-
if strings.HasPrefix(s, expectedPrefix){
207+
expectedPrefix := t.Name.Name + " "
208+
if strings.HasPrefix(s, expectedPrefix) {
209209
return
210210
}
211211
w.onFailure(lint.Failure{
@@ -244,7 +244,7 @@ func (w *lintExported) lintValueSpecDoc(vs *ast.ValueSpec, gd *ast.GenDecl, genD
244244
return
245245
}
246246

247-
if vs.Doc == nil && vs.Comment == nil && gd.Doc == nil {
247+
if vs.Doc == nil && gd.Doc == nil {
248248
if genDeclMissingComments[gd] {
249249
return
250250
}
@@ -348,7 +348,7 @@ func (w *lintExported) doCheckPublicInterface(typeName string, iface *ast.Interf
348348

349349
func (w *lintExported) lintInterfaceMethod(typeName string, m *ast.Field) {
350350
if len(m.Names) == 0 {
351-
return
351+
return
352352
}
353353
if !ast.IsExported(m.Names[0].Name) {
354354
return

testdata/golint/const-block.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
package foo
55

66
const (
7-
InlineComment = "ShouldBeOK" // InlineComment is a valid comment
7+
InlineComment = "ShouldBeOK" // InlineComment is not a valid documentation
8+
// MATCH:7 /exported const InlineComment should have comment (or a comment on this block) or be unexported/
89

9-
// Prefix for something.
1010
// MATCH /comment on exported const InlineWhatever should be of the form "InlineWhatever ..."/
1111
InlineWhatever = "blah"
1212

1313
Whatsit = "missing_comment"
14-
// MATCH:13 /exported const Whatsit should have comment (or a comment on this block) or be unexported/
1514

1615
// We should only warn once per block for missing comments,
16+
// thus do not warn on:13 /exported const Whatsit should have comment (or a comment on this block) or be unexported/
1717
// but always complain about malformed comments.
1818

1919
WhosYourDaddy = "another_missing_one"

0 commit comments

Comments
 (0)