Skip to content

Commit

Permalink
makes exported rule behave as golint (#1051)
Browse files Browse the repository at this point in the history
Co-authored-by: chavacava <salvador.cavadini@gmail.com>
  • Loading branch information
chavacava and chavacava authored Sep 29, 2024
1 parent fa37c00 commit 798ce21
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions rule/exported.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions testdata/golint/const-block.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 798ce21

Please sign in to comment.