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 committed Apr 17, 2024
1 parent 02a279e commit 6a4a170
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ This project adheres to [Semantic Versioning](https://semver.org/).
The format of this change log follows the advice given at [Keep a CHANGELOG](https://keepachangelog.com).

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

## [v3.4.6] - 2024-04-03
### Fixed
Expand Down
12 changes: 6 additions & 6 deletions moodle/Sniffs/Commenting/MissingDocblockSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,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 @@ -109,7 +109,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 @@ -196,9 +196,9 @@ protected function processFunctions(File $phpcsFile, int $stackPtr): void {
);
}
} elseif ($extendsOrImplements) {
$phpcsFile->addWarning('Missing docblock for %s %s', $typePtr, 'Missing', [$objectType, $objectName]);
$phpcsFile->addWarning('Missing docblock for %s %s', $typePtr, $objectType, [$objectType, $objectName]);
} 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 @@ -245,14 +245,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 6a4a170

Please sign in to comment.