Generic.WhiteSpaceDisallowSpaceIndent fixer bug when line only contains superfluous whitespace #1702
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When the
Generic.WhiteSpace.DisallowSpaceIndent
sniff encountered spaces on an otherwise empty line, the fixer would replace the spaces with tabs, remove the new line character and in effect prefix the whitespace to the next line.In other words, without the fix contains in this PR, this code snippet:
would be fixed as:
Includes unit test demonstrating the issue.
The fix in this PR results in this sniff ignoring lines which only contain whitespace.
Superfluous whitespace can be trimmed from lines using this
Squiz.WhiteSpace.SuperfluousWhitespace
sniff after all.Originally reported in WordPress/WordPress-Coding-Standards#1192
N.B.: I am aware that this PR will cause a merge conflict in the test files with my other PR involving this sniff #1599. I will rebase whichever PR needs it once either one of them has been merged.
As the issues are unrelated, a separate PR to fix this issue seems warranted.