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

Cobertura report generation emits NaN as complexity for some methods #606

Closed david-schneider-tfs closed 1 year ago

david-schneider-tfs commented 1 year ago

Describe the bug When using -reporttypes:Cobertura the resulting output file will have 'complexity="NaN"' for all methods that have parameters. This appears to be a regression as it is not an issue in 4.x versions

Based on a quick look through the code it appears that there is a discrepancy in the CoberturaParser and CoberturaReportBuilder.

In one case we're using methods by short name: Add(...) and in the other we're looking for methods using the long name: Add(System.Int32).

To Reproduce I've attached a sample file that can be used as an input that will show the issue. sampleCoberturaReport.txt

When that file is used as an input report, the output report will have the following:

...
<class name="Project1.Calculator" filename="" line-rate="0.8" branch-rate="0" complexity="2">
          <methods>
            <method name="Add" signature="(System.Int32)" line-rate="1" branch-rate="1" complexity="NaN">
              <lines>
                <line number="25" hits="28" branch="false" />
                <line number="26" hits="28" branch="false" />
              </lines>
            </method>
            <method name="AddOne" signature="()" line-rate="1" branch-rate="1" complexity="1">
              <lines>
                <line number="30" hits="2" branch="false" />
                <line number="31" hits="2" branch="false" />
              </lines>
            </method>
            <method name="Subtract" signature="(System.Int32)" line-rate="1" branch-rate="1" complexity="NaN">
              <lines>
                <line number="35" hits="28" branch="false" />
                <line number="36" hits="28" branch="false" />
              </lines>
            </method>
...

Both the Add and Subtract have a complexity of NaN where they didn't in the input report.

danielpalme commented 1 year ago

Thanks for reporting this issue. I will have a look within the next days.

danielpalme commented 1 year ago

Release 5.1.21 fixes your problem