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 a standard that uses Generic.WhiteSpace.ScopeIndent with tabIndent set to true. When running it on a certain piece of code, I got the following message:
"Line indented incorrectly; expected 4 tabs, found 4"
The sniff itself was correct, as the applicable code had been indented with 4 tabs, but also one stray space after, thus causing the error - but the message by itself doesn't really make sense as it reads that it satisfied the sniff.
Not the biggest bug. I guess it could be changed to say "found 4 tabs and 1 space" or something but I'm not really sure whether it'd be worth doing over other things, but just wanted to flag it.
The text was updated successfully, but these errors were encountered:
gsherwood
changed the title
Confusing message for Generic.WhiteSpace.ScopeIndent (with tabIndent on) when combination of tabs and spaces found
Generic.WhiteSpace.ScopeIndent confusing message when combination of tabs and spaces found
Apr 8, 2021
Thanks for reporting this - it was a confusing message.
Now, the message can come out in one of the following formats:
Line indented incorrectly; expected 1 tabs, found 3 spaces
Line indented incorrectly; expected 1 tabs, found 1 tabs and 1 spaces
Line indented incorrectly; expected 1 tabs, found 2
Hi,
I have a standard that uses Generic.WhiteSpace.ScopeIndent with tabIndent set to true. When running it on a certain piece of code, I got the following message:
"Line indented incorrectly; expected 4 tabs, found 4"
The sniff itself was correct, as the applicable code had been indented with 4 tabs, but also one stray space after, thus causing the error - but the message by itself doesn't really make sense as it reads that it satisfied the sniff.
The code in the sniff in question is https://github.com/squizlabs/PHP_CodeSniffer/blob/master/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php#L972 - where if it's tab-indented, the amount of the indent is floor()'d to the nearest tab width (usually 4) to print in the message. This seems to make sense if only tabs are being used, but if someone accidentally adds a space to a line, the floor() values for both expected and actual indent will round down to the same amount.
Not the biggest bug. I guess it could be changed to say "found 4 tabs and 1 space" or something but I'm not really sure whether it'd be worth doing over other things, but just wanted to flag it.
The text was updated successfully, but these errors were encountered: