tomasbjerre / violations-lib

Java library for parsing report files from static code analysis.
Apache License 2.0
148 stars 39 forks source link

Fix MyPy parser swallowing parts of error message #94

Closed yayachiken closed 4 years ago

yayachiken commented 4 years ago

It turns out that MyPy may print error messages that contain colons : which are used by the parser to delimit fields. This causes the parser to swallow the part of the error message between error: and the last colon : in the error message.

Fortunately we can just non-greedy match the error specifier as that most likely will always be an alphanumeric string and never contain a colon.

I've also written a test that displays the observed error behaviour. As I observed the actual bug in a work environment, I took an anonymous, equivalent error message from the MyPy test suite.

yayachiken commented 4 years ago

Note that there might still be another bug here as MyPy optionally allows for giving out line-colums in location specifiers (e.g. path/to/file.py:123:45: error: ... which should trigger a similar bug or maybe reject the line completely...

But I did not try to "fix" this as I have not yet used the columns option and do not know whether it is indeed a problem.

tomasbjerre commented 4 years ago

Thanks. Any specific tool you want released with this fix?

yayachiken commented 4 years ago

I noticed this bug in Jenkins and tracked this library down via:

But the bug is not super-critical for me personally, and those projects seem to regularily update their dependencies, so the fix will probably eventually trickle down.