-
Notifications
You must be signed in to change notification settings - Fork 268
Description
Bug
When trying to make SonarQube parse the XML coverage file produced with pyb coverage, I found out that in some cases parsing for root-level files fails, because a / is prepended to the filename attribute of the element.
This bug can be replicated by launching pyb coverage on PyBuilder itself and checking the produced target/reports/pybuilder_coverage.xml; for example, one can find:
<class name="__init__.py" filename="/pybuilder/__init__.py" complexity="0" line-rate="0" branch-rate="0">SonarQube's Python plugin treats filenames starting with / as absolute paths, thus failing to load them for analysis (source here).
Moreover, I noticed that the name attribute in the package element can also be shown in an undesirable way, like in:
<package name=".pybuilder" line-rate="0" branch-rate="0" complexity="0">Possible fix
I figured out a quick and dirty fix could be appending the OS's file separator to
| files.RELATIVE_DIR = source_path |
Please note that files.RELATIVE_DIR, before reassignment, always ends with the file separator.
This way, the examples above become:
<class name="__init__.py" filename="pybuilder/__init__.py" complexity="0" line-rate="0" branch-rate="0">and
<package name="pybuilder" line-rate="0.5534" branch-rate="0.6269" complexity="0">Thus leading to correct interpretation of the XML file by SonarQube.