]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Correctly identify `@todo` comments as TODOs.
authorJoshua Spence <josh@joshuaspence.com>
Tue, 4 Mar 2014 19:03:09 +0000 (11:03 -0800)
committerepriestley <git@epriestley.com>
Tue, 4 Mar 2014 19:03:09 +0000 (11:03 -0800)
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
src/lint/linter/__tests__/xhpast/todo.lint-test [new file with mode: 0644]

index 2e89bc35eaa6cb632b75cf29f9976b243e672e7d..9cf651d04cffbdbf4d9739cd7c331e256f9331b5 100644 (file)
@@ -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 (file)
index 0000000..4e7be6d
--- /dev/null
@@ -0,0 +1,10 @@
+<?php
+
+// TODO: Something goes here.
+
+/**
+ * @todo Something else goes here.
+ */
+~~~~~~~~~~
+disabled:3:4
+disabled:6:4