Chris@0: getFilename(), -3)); Chris@0: if ($fileExtension === 'txt' || $fileExtension === '.md') { Chris@0: $tokens = $phpcsFile->getTokens(); Chris@0: Chris@0: $content = rtrim($tokens[$stackPtr]['content']); Chris@0: $lineLength = mb_strlen($content, 'UTF-8'); Chris@0: // Lines without spaces are allowed to be longer (for example long URLs). Chris@17: // Markdown allowed to be longer for lines Chris@17: // - without spaces Chris@17: // - starting with # Chris@17: // - containing URLs (https://) Chris@17: // - starting with | (tables). Chris@17: if ($lineLength > 80 && preg_match('/^([^ ]+$|#|.*https?:\/\/|\|)/', $content) === 0) { Chris@0: $data = array( Chris@0: 80, Chris@0: $lineLength, Chris@0: ); Chris@0: $warning = 'Line exceeds %s characters; contains %s characters'; Chris@0: $phpcsFile->addWarning($warning, $stackPtr, 'TooLong', $data); Chris@0: } Chris@0: } Chris@0: Chris@0: }//end process() Chris@0: Chris@0: Chris@0: }//end class