From fb826bbf9cf05604ddf817e1acb8dda79a804242 Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Tue, 4 Mar 2014 11:03:09 -0800 Subject: [PATCH] Correctly identify `@todo` comments as TODOs. Summary: Allow `@todo` comments to be linted as TODOs as well as `TODO` comments. Test Plan: I added a new test case (`todo.lint-test`) Reviewers: #blessed_reviewers, epriestley Reviewed By: epriestley CC: Korvin, epriestley, aran Differential Revision: https://secure.phabricator.com/D8389 --- src/lint/linter/ArcanistXHPASTLinter.php | 8 +++++++- src/lint/linter/__tests__/xhpast/todo.lint-test | 10 ++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 src/lint/linter/__tests__/xhpast/todo.lint-test diff --git a/src/lint/linter/ArcanistXHPASTLinter.php b/src/lint/linter/ArcanistXHPASTLinter.php index 2e89bc35..9cf651d0 100644 --- a/src/lint/linter/ArcanistXHPASTLinter.php +++ b/src/lint/linter/ArcanistXHPASTLinter.php @@ -2036,9 +2036,15 @@ final class ArcanistXHPASTLinter extends ArcanistBaseXHPASTLinter { foreach ($comments as $token) { $value = $token->getValue(); + if ($token->getTypeName() === 'T_DOC_COMMENT') { + $regex = '/(TODO|@todo)/'; + } else { + $regex = '/TODO/'; + } + $matches = null; $preg = preg_match_all( - '/TODO/', + $regex, $value, $matches, PREG_OFFSET_CAPTURE); diff --git a/src/lint/linter/__tests__/xhpast/todo.lint-test b/src/lint/linter/__tests__/xhpast/todo.lint-test new file mode 100644 index 00000000..4e7be6dd --- /dev/null +++ b/src/lint/linter/__tests__/xhpast/todo.lint-test @@ -0,0 +1,10 @@ +