From c43cb34e2e33367805d62c448a1b16ef949c5210 Mon Sep 17 00:00:00 2001 From: Klaus Purer <klaus.purer@protonmail.ch> Date: Wed, 1 Jan 2025 18:42:40 +0100 Subject: [PATCH] fix(LineLength): Do not check phpcs:ignore lines for line length (#3477601) --- coder_sniffer/Drupal/Sniffs/Files/LineLengthSniff.php | 5 +++++ tests/Drupal/Files/LineLengthUnitTest.inc | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/coder_sniffer/Drupal/Sniffs/Files/LineLengthSniff.php b/coder_sniffer/Drupal/Sniffs/Files/LineLengthSniff.php index e959ceed..48210712 100644 --- a/coder_sniffer/Drupal/Sniffs/Files/LineLengthSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Files/LineLengthSniff.php @@ -54,6 +54,11 @@ class LineLengthSniff extends GenericLineLengthSniff protected function checkLineLength($phpcsFile, $tokens, $stackPtr) { if (isset(Tokens::$commentTokens[$tokens[($stackPtr - 1)]['code']]) === true) { + // Allow any PHPCS ignore comments to exceed the 80 character limit. + if (isset(Tokens::$phpcsCommentTokens[$tokens[($stackPtr - 1)]['code']]) === true) { + return; + } + $docCommentTag = $phpcsFile->findFirstOnLine(T_DOC_COMMENT_TAG, ($stackPtr - 1)); if ($docCommentTag !== false) { // Allow doc comment tags such as long @param tags to exceed the 80 diff --git a/tests/Drupal/Files/LineLengthUnitTest.inc b/tests/Drupal/Files/LineLengthUnitTest.inc index 8c0daabc..9a96802a 100644 --- a/tests/Drupal/Files/LineLengthUnitTest.inc +++ b/tests/Drupal/Files/LineLengthUnitTest.inc @@ -2,4 +2,13 @@ function foo() { echo 'test'; -}//end foo() \ No newline at end of file +}//end foo() + +class Test { + + /** + * The search score. + */ + public string $search_score; // phpcs:ignore Drupal.NamingConventions.ValidVariableName.LowerCamelName + +} -- GitLab