You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have just upgrade from CodeSniffer 1.x to 2.x and have come across what appears to be a bug in the way tabs are expanded. As far as I can see, this has existed since 2.0 and still exists in the latest 2.8 version. I have not tested on 3.x.
Consider the following (invalid, but illustrative) line in a file: 123 56 (the gap in the middle is a tab character, i.e. 123\t56)
Expected result (assuming a tab-width of 4 characters):
Translated content: " " (single space character)
Reported line length = 6
Actual result:
Translated content: " " (5 space characters)
Reported line length = 10
As far as I can see, the problem is in the calculation of $firstTabSize in Files.php on line 1542.
Instead of:
The reason I spotted this was because I suddenly started getting errors from Generic.Files.LineLength.MaxExceeded which I wasn't getting prior to the upgrade.
I am surprised no-one else has spotted this issue - I know this code path is only travelled for white-space composed entirely of tabs, but I wouldn't expect that to be particularly uncommon.
The text was updated successfully, but these errors were encountered:
With PSR-2 expansion tabs could be met rarely in source code whilst LineLength.MaxExceeded is just a warning in it :) Also, meeting such error there is a reflex just to change the line instead of calculating whether PHPCS calculation is correct or not. Nice boundary check!
gsherwood
changed the title
Error in tab expansion results in white-space of incorrect size.
Error in tab expansion results in white-space of incorrect size
Mar 3, 2017
Uh oh!
There was an error while loading. Please reload this page.
Hi there,
I have just upgrade from CodeSniffer 1.x to 2.x and have come across what appears to be a bug in the way tabs are expanded. As far as I can see, this has existed since 2.0 and still exists in the latest 2.8 version. I have not tested on 3.x.
Consider the following (invalid, but illustrative) line in a file:
123 56
(the gap in the middle is a tab character, i.e.123\t56
)Expected result (assuming a tab-width of 4 characters):
Actual result:
As far as I can see, the problem is in the calculation of
$firstTabSize
inFiles.php
on line 1542.Instead of:
it should be
The reason I spotted this was because I suddenly started getting errors from
Generic.Files.LineLength.MaxExceeded
which I wasn't getting prior to the upgrade.I am surprised no-one else has spotted this issue - I know this code path is only travelled for white-space composed entirely of tabs, but I wouldn't expect that to be particularly uncommon.
The text was updated successfully, but these errors were encountered: