Skip to content

Commit

Permalink
Fixed bug #2768 : Generic.Files.LineLength false positive for non-bre…
Browse files Browse the repository at this point in the history
…akable strings at exactly the soft limit
  • Loading branch information
gsherwood committed Dec 15, 2019
1 parent 120c713 commit 5c9586b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ http://pear.php.net/dtd/package-2.0.xsd">
-- Thanks to Matthew Peveler for the patch
- Fixed bug #2751 : Autoload relative paths first to avoid confusion with files from the global include path
-- Thanks to Klaus Purer for the patch
- Fixed bug #2768 : Generic.Files.LineLength false positive for non-breakable strings at exactly the soft limit
-- Thanks to Alex Miles for the patch
</notes>
<contents>
<dir name="/">
Expand Down
2 changes: 1 addition & 1 deletion src/Standards/Generic/Sniffs/Files/LineLengthSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ protected function checkLineLength($phpcsFile, $tokens, $stackPtr)
// to ignore the line length in these cases if the URL would be longer than the max
// line length once you indent it to the correct level.
if ($lineLength > $this->lineLimit) {
$oldLength = $tokens[$stackPtr]['length'];
$oldLength = strlen($tokens[$stackPtr]['content']);
$newLength = strlen(ltrim($tokens[$stackPtr]['content'], "/#\t "));
$indent = (($tokens[$stackPtr]['column'] - 1) + ($oldLength - $newLength));

Expand Down
9 changes: 9 additions & 0 deletions src/Standards/Generic/Tests/Files/LineLengthUnitTest.3.inc
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,12 @@ phpcs:set Generic.Files.LineLength absoluteLineLimit 150
/* This line is fine. This line is fine. This line is fine. This line is fine. This line is fine. */
/* This line is too long. This line is too long. This line is too long. This line is too long. This line is too long. This line is too long. */
/* This line is too long. This line is too long. This line is too long. This line is too long. This line is too long. This line is too long. This line is too long. */

/*
| ...
http://symfony.com/doc/current/cookbook/doctrine/dbal.html#registering-custom-mapping-types-in-the-schematoo
http://symfony.com/doc/current/cookbook/doctrine/dbal.html#registering-custom-mapping-types-in-the-schematool
http://symfony.com/doc/current/cookbook/doctrine/dbal.html#registering-custom-mapping-types-in-the-schematool1
http://symfony.com/doc/current/cookbook/doctrine/dbal.html#registering-custom-mapping-types-in-the-schematool12
| ...
*/

0 comments on commit 5c9586b

Please sign in to comment.