Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cobertura report shows NaN for all complexities #367

Closed
briangardner opened this issue Jul 31, 2020 · 6 comments · Fixed by #369
Closed

Cobertura report shows NaN for all complexities #367

briangardner opened this issue Jul 31, 2020 · 6 comments · Fixed by #369

Comments

@briangardner
Copy link

Expected Behavior
Creating the Cobertura report type should include Cycolmatic Complexity, and highlight Risk Hotspots.

Observed Behavior

  • Step 1: Run dotnet test --collect:"XPlat Code Coverage" --settings .\coverlet.runsettings.xml on a .Net Core 3.0 project
    • coverlet.runsettings.xml:
    <?xml version="1.0" encoding="utf-8" ?>
    <RunSettings>
      <DataCollectionRunSettings>
        <DataCollectors>
          <DataCollector friendlyName="XPlat code coverage">
            <Configuration>
              <Format>cobertura</Format>
              <Exclude>[*.Tests]*</Exclude>
              <IncludeTestAssembly>false</IncludeTestAssembly>
            </Configuration>
          </DataCollector>
        </DataCollectors>
      </DataCollectionRunSettings>
    </RunSettings>
    
  • Step 2: run reportgenerator "-reports:*\TestResults\*\*.xml" "-targetdir:coveragereport" -reporttypes:""HTMLInline_AzurePipelines;Cobertura" on a .Net Core 3.0 project,

The HTML Report shows cyclomatic complexity numbers, and risk hotspots as expected. The Cobertura.xml file has complexity="NaN" for every package, class, and method. And since all complexities are NaN, no Risk Hotspots show.

@eddynaka
Copy link
Contributor

eddynaka commented Aug 1, 2020

@danielpalme , I was looking at this and every place in CoberturaReportBuilder that prints complexity is pointing to NaN. Is it on purpose? Can i create a PR adding the logic to fill that value?

@danielpalme
Copy link
Owner

It's not as easy as it may seem.
ReportGenerators supports several input formats. Not every format contains the complexity metric.
ReportGenerator currently only tracks the metrics for each method (if available).
So adding this to the method elements should be doable.

All the other elements require quite a lot of work.
You'll have to take into account, that information is not available in all formats and that you have to support merging of results as well.

@eddynaka
Copy link
Contributor

eddynaka commented Aug 2, 2020 via email

@eddynaka
Copy link
Contributor

eddynaka commented Aug 2, 2020

@danielpalme , i opened the PR #369. Right now, with this changes i already added the complexity to:

  • method
  • file

And, trying to figure out how to add to package / root.

@danielpalme
Copy link
Owner

danielpalme commented Aug 2, 2020

Will test this in several scenarios. But may take a while, since I'm on vacation.

@danielpalme
Copy link
Owner

Merged this into develop branch.
Next release will contain your changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants