Skip to content
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

Fix 922 #989

Merged
merged 2 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 2 additions & 10 deletions rule/package-comments.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,17 +150,9 @@ func (l *lintPackageComments) Visit(_ ast.Node) ast.Visitor {
return nil
}
s := l.fileAst.Doc.Text()
if ts := strings.TrimLeft(s, " \t"); ts != s {
l.onFailure(lint.Failure{
Category: "comments",
Node: l.fileAst.Doc,
Confidence: 1,
Failure: "package comment should not have leading space",
})
s = ts
}

// Only non-main packages need to keep to this form.
if !l.file.Pkg.IsMain() && !strings.HasPrefix(s, prefix) {
if !l.file.Pkg.IsMain() && !strings.HasPrefix(s, prefix) && !isDirectiveComment(s) {
l.onFailure(lint.Failure{
Category: "comments",
Node: l.fileAst.Doc,
Expand Down
7 changes: 0 additions & 7 deletions testdata/golint/package-doc4.go

This file was deleted.

5 changes: 5 additions & 0 deletions testdata/golint/package-doc6.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//revive:disable
//nolint:dupl,revive // looks the same but isn't
//revive:enable

package foo // MATCH /should have a package comment/