Skip to content

Commit

Permalink
Make MissingDoclock code more specific (Fixes moodlehq#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols authored and stronk7 committed Jun 14, 2024
1 parent 3961e3c commit 932d86b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ The format of this change log follows the advice given at [Keep a CHANGELOG](htt

## [Unreleased]
### Added
- The existing `moodle.PHPUnit.TestCaseCovers` sniff now detects multiple uses of the `@coversDefaultClass` annotation. Only one is allowed by class.
- The existing `moodle.PHPUnit.TestCaseCovers` sniff now detects multiple uses of the `@coversDefaultClass` annotation. Only one is allowed by class.

### Changed
- Made codes for `moodle.Commenting.MissingDocblock` more specific to the scenario (Fixes #154).

## [v3.4.7] - 2024-05-31
### Added
Expand Down
10 changes: 5 additions & 5 deletions moodle/Sniffs/Commenting/MissingDocblockSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ protected function processScopes(File $phpcsFile, int $stackPtr): void {

if ($fileblock === null) {
$objectName = TokenUtil::getObjectName($phpcsFile, $stackPtr);
$phpcsFile->addError('Missing docblock for file %s', $stackPtr, 'Missing', [$objectName]);
$phpcsFile->addError('Missing docblock for file %s', $stackPtr, 'File', [$objectName]);
}
}

Expand All @@ -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, 'Missing', [$objectType, $objectName]);
$phpcsFile->addError('Missing docblock for %s %s', $typePtr, $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, 'Missing', [$objectType, $objectName]);
$phpcsFile->addError('Missing docblock for %s %s', $typePtr, $objectType, [$objectType, $objectName]);
}
}
}
Expand Down Expand Up @@ -255,14 +255,14 @@ protected function processConstants(File $phpcsFile, int $stackPtr): void {
$phpcsFile->addError(
'Missing docblock for constant %s::%s',
$typePtr,
'Missing',
'Constant',
[$containerName, $objectName]
);
} else {
$phpcsFile->addError(
'Missing docblock for constant %s',
$typePtr,
'Missing',
'Constant',
[$objectName]
);
}
Expand Down

0 comments on commit 932d86b

Please sign in to comment.