Skip to content

Commit d8d0ee4

Browse files
authored
checkers: recognize NOTE pattern in deprecatedComment (go-critic#770)
Fixes go-critic#643 Signed-off-by: Iskander Sharipov <[email protected]>
1 parent 09582e2 commit d8d0ee4

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

checkers/deprecatedComment_checker.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ func FuncOld() int`
2828
regexp.MustCompile(`(?i)this (?:function|type) is deprecated`),
2929
regexp.MustCompile(`(?i)deprecated[.!]? use \S* instead`),
3030
regexp.MustCompile(`(?i)\[\[deprecated\]\].*`),
31+
regexp.MustCompile(`(?i)note: deprecated\b.*`),
3132
// TODO(quasilyte): more of these?
3233
}
3334

checkers/testdata/deprecatedComment/negative_tests.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ type deprecated struct{}
1414

1515
// Derpecated is a type name.
1616
type Derpecated struct{}
17+
18+
// Note that this one is not deprecated.
19+
func f() {}

checkers/testdata/deprecatedComment/positive_tests.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,13 @@ var (
129129
// DERPecate: ...
130130
_ = 0
131131
)
132+
133+
/*! the proper format is `Deprecated: <text>` */
134+
// NOTE: Deprecated. Use bar instead.
135+
func foo1() {
136+
}
137+
138+
/*! the proper format is `Deprecated: <text>` */
139+
// NOTE: Deprecated.
140+
func foo2() {
141+
}

0 commit comments

Comments
 (0)