Skip to content

Commit

Permalink
Move unit test method Missing Docblock to new code
Browse files Browse the repository at this point in the history
This allows it to be ignored in phpcs.xml.
  • Loading branch information
andrewnicols committed Mar 20, 2024
1 parent 24bc48a commit 825a63e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion moodle/Sniffs/Commenting/MissingDocblockSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,14 @@ protected function processFunctions(File $phpcsFile, int $stackPtr): void {
$objectName = TokenUtil::getObjectName($phpcsFile, $typePtr);
$objectType = TokenUtil::getObjectType($phpcsFile, $typePtr);

if ($extendsOrImplements) {
if ($isUnitTestFile) {
$phpcsFile->addWarning(
'Missing docblock for %s %s',
$typePtr,
'MissingTestDescription',
[$objectType, $objectName]
);
} elseif ($extendsOrImplements) {
$phpcsFile->addWarning('Missing docblock for %s %s', $typePtr, 'Missing', [$objectType, $objectName]);
} else {
$phpcsFile->addError('Missing docblock for %s %s', $typePtr, 'Missing', [$objectType, $objectName]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public static function docblockCorrectnessProvider(): array {
3 => 'Missing docblock for class example_test',
],
'warnings' => [
12 => 'Missing docblock for function test_the_thing',
12 => 'Missing unit test docblock for function test_the_thing',
],
],
];
Expand Down

0 comments on commit 825a63e

Please sign in to comment.