Skip to content

Commit c43cb34

Browse files
authored
fix(LineLength): Do not check phpcs:ignore lines for line length (#3477601)
1 parent ce445b9 commit c43cb34

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

coder_sniffer/Drupal/Sniffs/Files/LineLengthSniff.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ class LineLengthSniff extends GenericLineLengthSniff
5454
protected function checkLineLength($phpcsFile, $tokens, $stackPtr)
5555
{
5656
if (isset(Tokens::$commentTokens[$tokens[($stackPtr - 1)]['code']]) === true) {
57+
// Allow any PHPCS ignore comments to exceed the 80 character limit.
58+
if (isset(Tokens::$phpcsCommentTokens[$tokens[($stackPtr - 1)]['code']]) === true) {
59+
return;
60+
}
61+
5762
$docCommentTag = $phpcsFile->findFirstOnLine(T_DOC_COMMENT_TAG, ($stackPtr - 1));
5863
if ($docCommentTag !== false) {
5964
// Allow doc comment tags such as long @param tags to exceed the 80

tests/Drupal/Files/LineLengthUnitTest.inc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,13 @@
22

33
function foo() {
44
echo 'test';
5-
}//end foo()
5+
}//end foo()
6+
7+
class Test {
8+
9+
/**
10+
* The search score.
11+
*/
12+
public string $search_score; // phpcs:ignore Drupal.NamingConventions.ValidVariableName.LowerCamelName
13+
14+
}

0 commit comments

Comments
 (0)