From d8d0ee479c0c0c9d4ef88bbb3a57c708d72d8e18 Mon Sep 17 00:00:00 2001 From: "Iskander (Alex) Sharipov" Date: Wed, 16 Jan 2019 14:54:27 +0000 Subject: [PATCH] checkers: recognize NOTE pattern in deprecatedComment (#770) Fixes #643 Signed-off-by: Iskander Sharipov --- checkers/deprecatedComment_checker.go | 1 + checkers/testdata/deprecatedComment/negative_tests.go | 3 +++ checkers/testdata/deprecatedComment/positive_tests.go | 10 ++++++++++ 3 files changed, 14 insertions(+) diff --git a/checkers/deprecatedComment_checker.go b/checkers/deprecatedComment_checker.go index ad40dbd4c..15235919c 100644 --- a/checkers/deprecatedComment_checker.go +++ b/checkers/deprecatedComment_checker.go @@ -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? } diff --git a/checkers/testdata/deprecatedComment/negative_tests.go b/checkers/testdata/deprecatedComment/negative_tests.go index a51f61cc4..08045c2a2 100644 --- a/checkers/testdata/deprecatedComment/negative_tests.go +++ b/checkers/testdata/deprecatedComment/negative_tests.go @@ -14,3 +14,6 @@ type deprecated struct{} // Derpecated is a type name. type Derpecated struct{} + +// Note that this one is not deprecated. +func f() {} diff --git a/checkers/testdata/deprecatedComment/positive_tests.go b/checkers/testdata/deprecatedComment/positive_tests.go index bacbf1228..6de204777 100644 --- a/checkers/testdata/deprecatedComment/positive_tests.go +++ b/checkers/testdata/deprecatedComment/positive_tests.go @@ -129,3 +129,13 @@ var ( // DERPecate: ... _ = 0 ) + +/*! the proper format is `Deprecated: ` */ +// NOTE: Deprecated. Use bar instead. +func foo1() { +} + +/*! the proper format is `Deprecated: ` */ +// NOTE: Deprecated. +func foo2() { +}