Skip to content

Commit 476ec01

Browse files
committed
Move unit test method Missing Docblock to new code
This allows it to be ignored in phpcs.xml.
1 parent 24bc48a commit 476ec01

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

moodle/Sniffs/Commenting/MissingDocblockSniff.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,9 @@ protected function processFunctions(File $phpcsFile, int $stackPtr): void {
180180
$objectName = TokenUtil::getObjectName($phpcsFile, $typePtr);
181181
$objectType = TokenUtil::getObjectType($phpcsFile, $typePtr);
182182

183-
if ($extendsOrImplements) {
183+
if ($isUnitTestFile) {
184+
$phpcsFile->addWarning('Missing unit test docblock for %s %s', $typePtr, 'MissingTestDescription', [$objectType, $objectName]);
185+
} elseif ($extendsOrImplements) {
184186
$phpcsFile->addWarning('Missing docblock for %s %s', $typePtr, 'Missing', [$objectType, $objectName]);
185187
} else {
186188
$phpcsFile->addError('Missing docblock for %s %s', $typePtr, 'Missing', [$objectType, $objectName]);

moodle/Tests/Sniffs/Commenting/MissingDocblockSniffTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public static function docblockCorrectnessProvider(): array {
136136
3 => 'Missing docblock for class example_test',
137137
],
138138
'warnings' => [
139-
12 => 'Missing docblock for function test_the_thing',
139+
12 => 'Missing unit test docblock for function test_the_thing',
140140
],
141141
],
142142
];

0 commit comments

Comments
 (0)