- Notifications
You must be signed in to change notification settings - Fork 541
baseline: normalize newlines in error messages #5
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't sufficient. You need to also make sure that a message containing \r\n
is ignored by ignoreErrors
item that contains only \n
. And to write an integration test in https://github.com/phpstan/phpstan-src/blob/master/tests/PHPStan/Command/ErrorFormatter/BaselineNeonErrorFormatterIntegrationTest.php that verifies everything actually works together.
Addded a unit test and fed data into the integration test, which failed for us in the real world app. hopefully that what you requested. |
We're still missing an integration test for BaselineNeonErrorFormatterIntegrationTest.php that would check that errors generated by a file with CRLF (that actually needs to be added to the repository) with baseline that generates only LF endings get also ignored. |
Because the changes in IgnoredError.php still aren't tested. |
I got the impression that the new method I added one one of the testclasses will generate a warning including a newline and therefore the lines should be covered? |
I think you need to add a new file that has CRLFs inside. I don't think that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved the test into this new file, which uses windows line endings.
also added a .gitattributes file, which should make sure that the line-endings for this file are enforced to CRLF
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we need to change this assertion because of the newly added testfiles under data/
Hi, please make sure that your build passes locally running |
easier said, then done :-). the tooling requires some non-standard php-extensions (e.g. ext-soap).
hopefully the travis build is finally green.. |
src/Analyser/IgnoredError.php Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wdyt about moving this message-normalization into a single spot? does a class exists in which this would fit in well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's fine like this :)
Hi, it's still quite weird. The formatter still generates this baseline with the
(I commented-out Also, if I comment out the preg_replace calls in IgnoredError.php, the tests still pass, which is weird. Can you investigate? Thanks. |
^^ My theory is that your preg_replace calls do not work at all and it's still filtering based on |
So baseline across platforms wouldn't work as expected. |
…use newline-format
I dont get why those chars are already escaped.. but it seems thats something that happens in phpstan somewhere... tried to fix it with the recent commits.. not 100% sure whether its correct that a newline in a neon-formatted file is represented as |
It's a newline inside regex inside neon. But when you're replacing it, it's still clean and unescaped. |
See: https://3v4l.org/Eeuch Your code didn't work... |
I expected the string to contain real newlines and work therefore like this: but nevertheless... :-) |
That's not how the error messages work. I'll look into it, thanks. |
@ondrejmirtes any chance to this into 0.12? |
I plan to include it in 0.12. |
OK, I did a few more tests and realized:
Anyway, I just merged this. Thank you! |
Thx for bringing it over the finish line |
Refs phpstan/phpstan#2558