Skip to content

Commit

Permalink
checkers: recognize NOTE pattern in deprecatedComment (go-critic#770)
Browse files Browse the repository at this point in the history
Fixes go-critic#643

Signed-off-by: Iskander Sharipov <[email protected]>
  • Loading branch information
quasilyte authored Jan 16, 2019
1 parent 09582e2 commit d8d0ee4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions checkers/deprecatedComment_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func FuncOld() int`
regexp.MustCompile(`(?i)this (?:function|type) is deprecated`),
regexp.MustCompile(`(?i)deprecated[.!]? use \S* instead`),
regexp.MustCompile(`(?i)\[\[deprecated\]\].*`),
regexp.MustCompile(`(?i)note: deprecated\b.*`),
// TODO(quasilyte): more of these?
}

Expand Down
3 changes: 3 additions & 0 deletions checkers/testdata/deprecatedComment/negative_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ type deprecated struct{}

// Derpecated is a type name.
type Derpecated struct{}

// Note that this one is not deprecated.
func f() {}
10 changes: 10 additions & 0 deletions checkers/testdata/deprecatedComment/positive_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,13 @@ var (
// DERPecate: ...
_ = 0
)

/*! the proper format is `Deprecated: <text>` */
// NOTE: Deprecated. Use bar instead.
func foo1() {
}

/*! the proper format is `Deprecated: <text>` */
// NOTE: Deprecated.
func foo2() {
}

0 comments on commit d8d0ee4

Please sign in to comment.