Skip to content
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
12 changes: 10 additions & 2 deletions BigBite/Sniffs/Commenting/DocCommentLineLengthSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@ final class DocCommentLineLengthSniff implements Sniff {
/**
* Specific comment prefixes to ignore.
*
* If a comment line begins with any of these prefixes,
* the line length calculations should be skipped for that line.
*
* @var array<int,string>
*/
public $descriptorsToIgnore = array(
'Plugin Name:',
'Theme Name:',
'Description:',
);

/**
Expand Down Expand Up @@ -118,6 +120,12 @@ public function process( File $phpcsFile, $stackPtr ) {
continue;
}

foreach ( $this->descriptorsToIgnore as $ignoreThisPrefix ) {
if ( 0 === strpos( $tokens[ $i ]['content'], $ignoreThisPrefix ) ) {
continue 2;
}
}

$isAParameterDescription = false;

$lineLength = $tokens[ $i ]['length'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,7 @@
*/

/**
* Plugin Name: Line lengths
* Description: WordPress plugin/theme comment line lengths are excluded from this sniff.
*/

/**
* Theme Name: Line lengths
* Description: WordPress plugin/theme comment line lengths are excluded from this sniff, both soft limit and hard limit.
* Description: comment lines that begin with the "Description:" prefix are excluded from this sniff, both soft limit and hard limit.
*/

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@
*/

/**
* Plugin Name: Line lengths
* Description: WordPress plugin/theme comment line lengths are excluded from this sniff.
*/

/**
* Theme Name: Line lengths
* Description: WordPress plugin/theme comment line lengths are excluded from this sniff, both soft limit and hard limit.
* Description: comment lines that begin with the "Description:" prefix are excluded from this sniff, both soft limit and hard limit.
*/

/**
Expand Down
4 changes: 2 additions & 2 deletions BigBite/Tests/Commenting/DocCommentLineLengthUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function getErrorList( $testFile = '' ) {
case 'DocCommentLineLengthUnitTest.1.inc':
return array(
8 => 1,
45 => 1,
39 => 1,
);
case 'DocCommentLineLengthUnitTest.2.inc':
return array(
Expand Down Expand Up @@ -75,7 +75,7 @@ public function getWarningList( $testFile = '' ) {
case 'DocCommentLineLengthUnitTest.1.inc':
return array(
4 => 1,
38 => 1,
32 => 1,
);
case 'DocCommentLineLengthUnitTest.2.inc':
return array(
Expand Down