Skip to content

Commit 3845421

Browse files
arp242dominikh
authored andcommitted
ST1020: allow comments to start with deprecation comment
Closes: gh-1378 Closes: gh-1549 [via git-merge-pr]
1 parent becc0c6 commit 3845421

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

stylecheck/st1020/st1020.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ func run(pass *analysis.Pass) (interface{}, error) {
5555
if !ast.IsExported(decl.Name.Name) {
5656
return
5757
}
58+
if strings.HasPrefix(text, "Deprecated: ") {
59+
return
60+
}
61+
5862
kind := "function"
5963
if decl.Recv != nil {
6064
kind = "method"

stylecheck/st1020/testdata/go1.0/CheckExportedFunctionDocs/CheckExportedFunctionDocs.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ func (T) Foo() {}
2020
// Whatever //@ diag(`comment on exported method`)
2121
func (T) Bar() {}
2222

23+
// Deprecated: don't use.
24+
func (T) Dep() {}
25+
2326
//
2427
func Qux() {} // this is fine, because "no comment" and "empty comment" are treated the same
2528

@@ -41,3 +44,15 @@ func F2() {}
4144
//some:directive //@ diag(`comment on exported function`)
4245
// Whatever
4346
func F3() {}
47+
48+
// Deprecated: don't use.
49+
func F4() {}
50+
51+
//some:directive
52+
// Deprecated: don't use.
53+
func F5() {}
54+
55+
// wrong comment yo. //@diag (`comment on exported function`)
56+
//
57+
// Deprecated: don't use.
58+
func F6() {}

stylecheck/st1020/testdata/go1.18/CheckExportedFunctionDocs/generics.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,15 @@ func (TPT2[T1, T2]) Foo() {}
2424

2525
// Whatever //@ diag(`comment on exported method`)
2626
func (*TPT2[T1, T2]) Bar() {}
27+
28+
// Deprecated: don't use.
29+
func TPFooDepr[T any]() {}
30+
31+
// Deprecated: don't use.
32+
func TPBarDepr[T1, T2 any]() {}
33+
34+
// Deprecated: don't use.
35+
func (TPT[T]) BarDepr() {}
36+
37+
// Deprecated: don't use.
38+
func (*TPT2[T1, T2]) BarDepr() {}

0 commit comments

Comments
 (0)