Write coverage in the generic test data XML format read by SonarQube.
Arguments
- x
the coverage object returned from
package_coverage()- file
the name of the SonarQube Generic XML file
- path_prefix
SonarQube expects file paths relative to the project's base directory. By default the paths are relative to the package root (e.g.
R/foo.R), which is correct when the package is the root of the SonarQube project. If the package is in a subdirectory of the project, setpath_prefixto that subdirectory (e.g."pkg"givespkg/R/foo.R).
Details
Every line with coverage is reported as a lineToCover with its lineNumber
and whether it is covered, including the lines of compiled code. Each line
is reported once: when several functions share a line, it is only covered if
all its code was run, as in report() and percent_coverage().
Branches are only reported if they were measured with
options(covr.branch_coverage = TRUE) (see covr.branch_coverage). A line
where an if or switch() starts then also has branchesToCover, the
number of branches of the if and switch() calls on the line, and
coveredBranches, how many of them were taken.
This functionality requires the xml2 package be installed.
