Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions coder_sniffer/Drupal/Sniffs/Commenting/TodoCommentSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,12 @@ private function checkTodoFormat(File $phpcsFile, $stackPtr, string $comment)
}

$expression = '/(?x) # Set free-space mode to allow this commenting
^(\/\/)? # At the start optionally match two forward slashes
\s* # then any amount of whitespace
^(\/|\s)* # At the start optionally match any forward slashes and spaces
(?i) # set case-insensitive mode
(?=( # start a postive non-consuming look-ahead to find all possible todos
@+to(-|\s|)+do # if one or more @ allow space or - between the to and do
@+to(-|\s|)+do # if one or more @ allow spaces and - between the to and do
| # or
to(-)*do # if no @ then only accept todo or to-do or to--do, etc
to(-)*do # if no @ then only accept todo or to-do or to--do, etc, no spaces
))
(?-i) # Reset to case-sensitive
(?! # Start another non-consuming look-ahead, this time negative
Expand Down
17 changes: 10 additions & 7 deletions tests/Drupal/Commenting/TodoCommentUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@
* @TODo Error
* @ToDO Error
* @todo: Error
* @todo : Error
* @to-do Error
* @TO-DO Error
* @To-Do Error
* @TO do Error
* @to do Error
* @todo: Error
* @todo : Error
* @to do Error
* @todo- Error
* @todo - Error
* @todoError
* @todo Error
* todo Error
* TODO Error
* ToDo Error
* @todo Error
* to-do Error
*/

function foo() {
Expand All @@ -38,24 +38,27 @@ function foo() {
// @todo $can start with a $
// @todo \also with backslash

// 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.
// @TODO Error
// @ToDo Error
// @TODo Error
// @ToDO Error
// @todo: Error
// @todo : Error
// @to-do Error
// @TO-DO Error
// @To-Do Error
// @TO do Error
// @to do Error
// @todo: Error
// @todo : Error
// @todo Error
// @todo- Error
// @todo - Error
// @todoError
// todo Error
// TODO Error
// ToDo Error
// @todo Error
// to-do Error
}
2 changes: 1 addition & 1 deletion tests/Drupal/Commenting/TodoCommentUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class TodoCommentUnitTest extends CoderSniffUnitTest
*/
protected function getErrorList(string $testFile): array
{
$errorList = (array_fill_keys(range(13, 31), 1) + array_fill_keys(range(42, 60), 1));
$errorList = (array_fill_keys(range(13, 31), 1) + array_fill_keys(range(45, 63), 1));
return $errorList;

}//end getErrorList()
Expand Down