Skip to content

Commit

Permalink
Make new codes to have upper first chat + tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed Jun 14, 2024
1 parent 932d86b commit f3675a6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
4 changes: 2 additions & 2 deletions moodle/Sniffs/Commenting/MissingDocblockSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ protected function processScopes(File $phpcsFile, int $stackPtr): void {
$objectName = TokenUtil::getObjectName($phpcsFile, $typePtr);
$objectType = TokenUtil::getObjectType($phpcsFile, $typePtr);

$phpcsFile->addError('Missing docblock for %s %s', $typePtr, $objectType, [$objectType, $objectName]);
$phpcsFile->addError('Missing docblock for %s %s', $typePtr, ucfirst($objectType), [$objectType, $objectName]);
}

if ($artifactCount === 1) {
Expand Down Expand Up @@ -208,7 +208,7 @@ protected function processFunctions(File $phpcsFile, int $stackPtr): void {
);
}
} else {
$phpcsFile->addError('Missing docblock for %s %s', $typePtr, $objectType, [$objectType, $objectName]);
$phpcsFile->addError('Missing docblock for %s %s', $typePtr, ucfirst($objectType), [$objectType, $objectName]);
}
}
}
Expand Down
22 changes: 21 additions & 1 deletion moodle/Tests/Sniffs/Commenting/MissingDocblockSniffTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function testMissingDocblockSniff(

public static function docblockCorrectnessProvider(): array {
$cases = [
'Multiple artifacts in a file' => [
'Multiple artifacts in a file, check messages' => [
'fixture' => 'multiple_artifacts',
'fixtureFilename' => null,
'errors' => [
Expand All @@ -72,6 +72,26 @@ public static function docblockCorrectnessProvider(): array {
'warnings' => [
],
],
'Multiple artifacts in a file, check codes' => [
'fixture' => 'multiple_artifacts',
'fixtureFilename' => null,
'errors' => [
1 => 'moodle.Commenting.MissingDocblock.File',
34 => 'moodle.Commenting.MissingDocblock.Function',
38 => 'moodle.Commenting.MissingDocblock.Class',
95 => 'moodle.Commenting.MissingDocblock.Interface',
118 => 'moodle.Commenting.MissingDocblock.Trait',
151 => 'moodle.Commenting.MissingDocblock.Function',
159 => 'moodle.Commenting.MissingDocblock.Function',
166 => 'moodle.Commenting.MissingDocblock.Function',
170 => 'moodle.Commenting.MissingDocblock.Class',
171 => 'moodle.Commenting.MissingDocblock.Function',
175 => 'moodle.Commenting.MissingDocblock.Class',
176 => 'moodle.Commenting.MissingDocblock.Function',
],
'warnings' => [
],
],
'File level tag, no class' => [
'fixture' => 'class_without_docblock',
'fixtureFilename' => null,
Expand Down

0 comments on commit f3675a6

Please sign in to comment.