diff --git a/coder_sniffer/Drupal/Sniffs/Commenting/TodoCommentSniff.php b/coder_sniffer/Drupal/Sniffs/Commenting/TodoCommentSniff.php index 2392f9b8..4837ab1f 100644 --- a/coder_sniffer/Drupal/Sniffs/Commenting/TodoCommentSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Commenting/TodoCommentSniff.php @@ -142,7 +142,7 @@ private function checkTodoFormat(File $phpcsFile, int $stackPtr, string $comment (?-i) # Reset to case-sensitive (?! # Start another non-consuming look-ahead, this time negative @todo\s # It has to match lower-case @todo followed by one space - (?!-|:)\S # and then any non-space except "-" or ":". + (?!-|:)[A-Z] # and then any capital letter except "-" or ":". )/m'; if ((bool) preg_match($expression, $comment, $matches) === true) { diff --git a/tests/Drupal/Commenting/TodoCommentUnitTest.inc b/tests/Drupal/Commenting/TodoCommentUnitTest.inc index 02a103d2..86b8797f 100644 --- a/tests/Drupal/Commenting/TodoCommentUnitTest.inc +++ b/tests/Drupal/Commenting/TodoCommentUnitTest.inc @@ -7,9 +7,9 @@ * These are valid examples. * * @todo Valid. - * @todo valid with lower-case first letter - * @todo $can start with a $ - * @todo \also with backslash + * @todo Valid + * @todo Multiple words are valid. + * @todo Multiple words are valid * * These are all incorrect but can be fixed automatically. * @@ -38,6 +38,7 @@ * @todo * @to-do * @TODO + * @todo this should be uppercase */ /** @@ -46,6 +47,7 @@ function foo() { // These are valid examples. // @todo Valid. + // These are invalid since they don't start with a capital letter. // @todo valid with lower-case first letter // @todo $can start with a $ // @todo \also with backslash diff --git a/tests/Drupal/Commenting/TodoCommentUnitTest.inc.fixed b/tests/Drupal/Commenting/TodoCommentUnitTest.inc.fixed index d4822539..795be0ad 100644 --- a/tests/Drupal/Commenting/TodoCommentUnitTest.inc.fixed +++ b/tests/Drupal/Commenting/TodoCommentUnitTest.inc.fixed @@ -7,9 +7,9 @@ * These are valid examples. * * @todo Valid. - * @todo valid with lower-case first letter - * @todo $can start with a $ - * @todo \also with backslash + * @todo Valid + * @todo Multiple words are valid. + * @todo Multiple words are valid * * These are all incorrect but can be fixed automatically. * @@ -38,6 +38,7 @@ * @todo * @todo * @todo + * @todo this should be uppercase */ /** @@ -46,9 +47,10 @@ function foo() { // These are valid examples. // @todo Valid. - // @todo valid with lower-case first letter - // @todo $can start with a $ - // @todo \also with backslash + // These are invalid since they don't start with a capital letter. + // @todo Error + // @todo Error + // @todo Error // This is not a todo tag. It is a general comment and we do not want // to do the standards checking here. // These are all incorrect but can be fixed automatically. diff --git a/tests/Drupal/Commenting/TodoCommentUnitTest.php b/tests/Drupal/Commenting/TodoCommentUnitTest.php index d50ecd73..9f7b5305 100644 --- a/tests/Drupal/Commenting/TodoCommentUnitTest.php +++ b/tests/Drupal/Commenting/TodoCommentUnitTest.php @@ -37,7 +37,9 @@ protected function getErrorList(string $testFile): array */ protected function getWarningList(string $testFile): array { - $warningList = (array_fill_keys(range(16, 34), 1) + array_fill_keys(range(38, 40), 1) + array_fill_keys(range(55, 73), 1) + array_fill_keys(range(75, 77), 1)); + $warningList = ( + array_fill_keys(range(16, 34), 1) + array_fill_keys(range(38, 41), 1) + array_fill_keys(range(51, 53), 1) + array_fill_keys(range(57, 75), 1) + array_fill_keys(range(77, 79), 1) + ); return $warningList; }//end getWarningList() diff --git a/tests/Drupal/good/good.php b/tests/Drupal/good/good.php index 2f36e561..6cd5617f 100644 --- a/tests/Drupal/good/good.php +++ b/tests/Drupal/good/good.php @@ -769,7 +769,7 @@ function test3() { // Comment one. t('x'); // Comment two. -// @todo this is valid! +// @todo This is valid! t('x'); // Goes on? t('x');