coala / coala-bears

Bears for coala
https://coala.io/
GNU Affero General Public License v3.0
295 stars 580 forks source link

XMLBear: Regex swallows results when using different flags of xmllint #2046

Open Makman2 opened 6 years ago

Makman2 commented 6 years ago

I've found out that the tests show different reporting behaviour of xmllint. For example one of the simple invalid-xml-tests produce following xmllint output:

test.xml:2: parser error : Start tag expected, '<' not found
+<a>hey & hi</a>
^

As you see there are two context lines, which we don't need in coala. Hence the final .*\n.*\n inside the parsing regex:

.*:(?P<line>\d+):.*(?P<severity>error|warning)\s?: (?P<message>.*)\n.*\n.*')

However, when e.g. using the dtd-validation, this swallows results, as then no context lines are presented:

test_files/dtd-error.xml:6: element note: validity error : Element note content does not follow the DTD, expecting (to , from , heading , body), got (to from heading body footer )
test_files/dtd-error.xml:11: element footer: validity error : No declaration for element footer
Document test_files/dtd-error.xml does not validate against test_files/note.dtd

So we need to catch the different operating modes (or in worst case, we even we have to detect the error type!) and choose a more appropriate regex.

Makman2 commented 6 years ago

I want to have better tests before we fix this, to be sure this doesn't sneak in again.

Blocked by https://github.com/coala/coala-bears/issues/2045

Mixih commented 6 years ago

Assigned as a part of GSoC project "Improve Linter Bears". Do not reassign for the duration of the coding period unless the assignee releases the issue themselves.

Makman2 commented 6 years ago

This belongs to the coala-bears repo.

@jayvdb can you migrate this issue when you have time? I don't have a laptop available right now.

sangamcse commented 6 years ago

@Makman2, this one here is already in coala-bears repo.

Makman2 commented 6 years ago

What the heck I've seen here... nvm at all :sweat_smile: