Class name invalid for gcov parser
See original GitHub issueDescribe the bug When I use ReportGenerator to convert a gcov report to a cobertura report, the file path is not stripped from the class name.
To reproduce
- Generate a coverage file with lcov.
test_coverage.infowith contents like
...
TN:
SF:/home/agent/src/internal/MasterInternal.h
DA:10,0
DA:24,0
end_of_record
...
-
Invoke ReportGenerator like this
ReportGenerator -reports:./test_coverage.info -sourcedirs:/home/agent/src -targetdir:./Results/ -reporttypes:Cobertura -
Take a look at the generated
./Results/Cobertura.xmlfile:
<class name="/home/agent/src/internal/MasterInternal.h" filename="/home/agent/src/internal/MasterInternal.h" line-rate="1" branch-rate="1" complexity="NaN">
....
</class>
- The expected output should be:
<class name="MasterInternal.h" filename="/home/agent/src/internal/MasterInternal.h" line-rate="1" branch-rate="1" complexity="NaN">
....
</class>
Why is this a problem?
I later merge reports together using ReportGenerator with -reporttypes:HtmlInline_AzurePipelines.
Classnames containing a path like this, are not correctly rendered in the report.
Possible Fix
https://github.com/danielpalme/ReportGenerator/blob/main/src/ReportGenerator.Core/Parser/GCovParser.cs#L89
~var @class = new Class(fileName, assembly);~
var @class = new Class(className, assembly);
Issue Analytics
- State:
- Created a year ago
- Comments:12 (6 by maintainers)

Top Related StackOverflow Question
Now it works ☺️ . Thank you.
Fantastic work. Thank you so much.