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

Various sniffs: simplify skipping the rest of the file #385

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Yoast/Sniffs/Commenting/FileCommentSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function process( File $phpcsFile, $stackPtr ) {

if ( $comment_start === false || $tokens[ $comment_start ]['code'] !== \T_DOC_COMMENT_OPEN_TAG ) {
// No file comment found, we're good.
return ( $phpcsFile->numTokens + 1 );
return $phpcsFile->numTokens;
}

// Respect phpcs:disable comments in the file docblock.
Expand All @@ -110,7 +110,7 @@ public function process( File $phpcsFile, $stackPtr ) {
|| isset( $tokens[ $i ]['sniffCodes']['Yoast.Commenting.FileComment.Unnecessary'] ) === true
) {
// Applicable disable annotation found.
return ( $phpcsFile->numTokens + 1 );
return $phpcsFile->numTokens;
}
}
}
Expand All @@ -136,6 +136,6 @@ public function process( File $phpcsFile, $stackPtr ) {
'Unnecessary'
);

return ( $phpcsFile->numTokens + 1 );
return $phpcsFile->numTokens;
}
}
6 changes: 3 additions & 3 deletions Yoast/Sniffs/Files/FileNameSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function process( File $phpcsFile, $stackPtr ) {
$file = TextStrings::stripQuotes( $phpcsFile->getFileName() );

if ( $file === 'STDIN' ) {
return ( $phpcsFile->numTokens + 1 ); // @codeCoverageIgnore
return $phpcsFile->numTokens; // @codeCoverageIgnore
}

// Respect phpcs:disable comments as long as they are not accompanied by an enable.
Expand All @@ -167,7 +167,7 @@ public function process( File $phpcsFile, $stackPtr ) {

if ( $i === false ) {
// The entire (rest of the) file is disabled.
return ( $phpcsFile->numTokens + 1 );
return $phpcsFile->numTokens;
}
}
}
Expand Down Expand Up @@ -278,7 +278,7 @@ public function process( File $phpcsFile, $stackPtr ) {
}

// Only run this sniff once per file, no need to run it again.
return ( $phpcsFile->numTokens + 1 );
return $phpcsFile->numTokens;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions Yoast/Sniffs/Files/TestDoublesSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function process( File $phpcsFile, $stackPtr ) {
$file = TextStrings::stripQuotes( $phpcsFile->getFileName() );

if ( $file === 'STDIN' ) {
return; // @codeCoverageIgnore
return $phpcsFile->numTokens; // @codeCoverageIgnore
}

if ( ! isset( $phpcsFile->config->basepath ) ) {
Expand All @@ -81,7 +81,7 @@ public function process( File $phpcsFile, $stackPtr ) {
'MissingBasePath'
);

return ( $phpcsFile->numTokens + 1 );
return $phpcsFile->numTokens;
}

if ( empty( $this->doubles_path ) ) {
Expand All @@ -92,7 +92,7 @@ public function process( File $phpcsFile, $stackPtr ) {
'NoDoublesPathProperty'
);

return ( $phpcsFile->numTokens + 1 );
return $phpcsFile->numTokens;
}

if ( ! isset( $this->target_paths ) || \defined( 'PHP_CODESNIFFER_IN_TESTS' ) ) {
Expand Down