-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error in tab expansion results in white-space of incorrect size #1373
Comments
With PSR-2 expansion tabs could be met rarely in source code whilst |
Thanks a lot for reporting and fixing this. It is strange that it has never come up, but was clearly wrong on those tab boundaries. |
:-) No problem. Thanks for accepting it so quickly. |
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: