Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-add fullstop to @throws if rule is used #3455

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -45,7 +45,7 @@ public function getErrorList($testFile='')
switch ($testFile) {
case 'ExecutableFileUnitTest.2.inc':
case 'ExecutableFileUnitTest.4.inc':
return [1 => 1];
return [1 => 0];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you're trying to do here, but this change should be undone as this is the test file for an unrelated sniff.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really sure what changed either but without this change this unit test fails...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did you run the tests to come to that conclusion ?
The last CI build passed without problems, so unless you changed something either in the test files or in the sniff, there should be no reason why the tests would fail.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI - this particular test is skipped in a few cases, could it be that the way you are running the tests falls under the "skip" conditions, but isn't identified correctly ? In that case, fixing the condition would be a good thing, but that should still be done in a separate PR as it would constitute a different decision point than the decision for whether or not to accept this PR.

protected function shouldSkipTest()
{
// PEAR doesn't preserve the executable flag, so skip
// tests when running in a PEAR install.
// Also skip on Windows which doesn't have the concept of executable files.
return ($GLOBALS['PHP_CODESNIFFER_PEAR'] || (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'));
}//end shouldSkipTest()

default:
return [];
}//end switch
Expand Down
Expand Up @@ -241,7 +241,7 @@ protected function processThrows(File $phpcsFile, $stackPtr, $commentStart)

for ($i = ($tag + 3); $i < $end; $i++) {
if ($tokens[$i]['code'] === T_DOC_COMMENT_STRING) {
$comment .= ' '.$tokens[$i]['content'];
$comment .= ' ' . $tokens[$i]['content'];
pascalheidmann marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand All @@ -255,7 +255,11 @@ protected function processThrows(File $phpcsFile, $stackPtr, $commentStart)
$lastChar = substr($comment, -1);
if ($lastChar !== '.') {
$error = '@throws tag comment must end with a full stop';
$phpcsFile->addError($error, ($tag + 2), 'ThrowsNoFullStop');
$fix = $phpcsFile->addFixableError($error, ($tag + 2), 'ThrowsNoFullStop');

if ($fix) {
$phpcsFile->fixer->replaceToken(($tag + 2), $tokens[($tag + 2)]['content'] . '.');
pascalheidmann marked this conversation as resolved.
Show resolved Hide resolved
}
}
}//end if
}//end foreach
Expand Down
Expand Up @@ -196,7 +196,7 @@ public function noReturnOutsideClass()
* @see
* @return void
* @extra Invalid tag
* @throws UnknownException unknown
* @throws UnknownException unknown.
*/
public function missingTwoParamComment($one, $two, $three)
{
Expand Down