danielpalme / ReportGenerator

ReportGenerator converts coverage reports generated by coverlet, OpenCover, dotCover, Visual Studio, NCover, Cobertura, JaCoCo, Clover, gcov or lcov into human readable reports in various formats.
https://reportgenerator.io
Apache License 2.0
2.62k stars 283 forks source link

Duplicate method names in Cobertura Reports #687

Closed philippjenni closed 2 months ago

philippjenni commented 2 months ago

Describe the bug If I create a Cobertura report from different 2 XML Coverage Reports, it can happen that methods are listed twice in the generated Cobertura report, which is not permitted for Cobertura.

To Reproduce The following input helps to reproduce your issue:

  1. Create a coverage report from 2 or more XML reports, which methods are executed the same methods in both coverage reports.

The generated XML should now contain multiple methods for the classes. The name and signature are identical.

philippjenni commented 2 months ago

I have tried to solve the problem in a branch by adapting the report accordingly. I will create a PR, but it still needs to be checked. I'm not sure if the correction is in the right place. But the error has been fixed with the patch.

danielpalme commented 2 months ago

Thank you. Will have a look next week.

danielpalme commented 2 months ago

Currently I'm not able to reproduce your problem?

Could you please share two (minimal) input XML files? You can send them privately via email: reportgenerator@palmmedia.de or share them here.

danielpalme commented 2 months ago

Thanks for the files. Will have look soon.

danielpalme commented 2 months ago

I just analyzed your coverage files.

Your code base contains classes with nested classes. By default, ReportGenerator treats a class and all nested types as one unit. This is good in case you want to generate a HTML report.

If you want to generate a Cobertura file, this behavior is not perfect. Now methods with the same name in different nested classes appear under one parent class. Merging them, as your pull requests suggests, is also technically not correct. You are merging methods from different classes (e.g. .ctor).

But there is a better solution. You can use the command line parameter settings:rawMode=true

See this comment for all details: https://github.com/danielpalme/ReportGenerator/issues/630#issuecomment-2008130255