-
-
Notifications
You must be signed in to change notification settings - Fork 61
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
Reports: Fix word wrapping edge cases #654
base: master
Are you sure you want to change the base?
Conversation
The word wrapping in Code and Full reports did not correctly account for the ANSI color codes (producing differently wrapped text depending on the value of $showSources) and for the PHP_EOL constant values (producing differently wrapped text on Linux and Windows). Rewrite the code so that word wrapping is done first, and padding and colors are added afterwards. Also harmonize the implementation between the two reports.
@MatmaRex Thank you for your interest in contributing to PHP_CodeSniffer. To understand what this PR is trying to solve, could you please add some screenshots of "before" and "after" highlighting what the problem is supposed to be ? Some previous issues/PRs related to these reports and wrapping: squizlabs/PHP_CodeSniffer#196, squizlabs/PHP_CodeSniffer#2093, #124, #125, #154 |
Regarding tests: this part of the codebase absolutely needs tests, but those haven't been created yet. It's part of the reason why I linked to those previous PRs, as - as things are now without tests - it is a little too easy to bring back previously fixed bugs when creating a new fix. |
I can try adding tests, but I'm reluctant to make large additions as my first patch. I'm also not sure if this part of the codebase is unit-testable, I might end up with an ugly fragile integration test you might not want to maintain. But I will at least make up a small test case reproducible manually. I'll look into this after the weekend. (I originally encountered the problem while running integration tests for a CodeSniffer ruleset we maintain. For example, this sample output is poorly wrapped due to the presence of color codes: https://gerrit.wikimedia.org/g/mediawiki/tools/codesniffer/+/9423de5e375150f09dba44093cbdab939afd3489/MediaWiki/Tests/files/code_sample.php.expect#99) |
I still don't see what problem you are trying to solve. Even if I were to manually test the patch, I still need to be able to reproduce the problem and verify the fix. As things are, there is just not enough information for this. |
I'm working on an example at https://github.com/MatmaRex/phpcs-pull-654-demo, but it's difficult to provide a concise demo, because PHPCS output differs in other ways on Windows and Linux. Perhaps you may accept a patch for that as well? #662 |
Description
The word wrapping in Code and Full reports did not correctly account for the ANSI color codes (producing differently wrapped text depending on the value of
$showSources
) and for thePHP_EOL
constant values (producing differently wrapped text on Linux and Windows).Rewrite the code so that word wrapping is done first, and padding and colors are added afterwards.
Also harmonize the implementation between the two reports.
Suggested changelog entry
(probably not needed)
Related issues/external references
(none)
Types of changes
PR checklist
(Not applicable? I didn't find any tests for the reports classes, I assume this is not meant to be covered)
(Not applicable)