Code Monkey home page Code Monkey logo

Comments (12)

danielpalme avatar danielpalme commented on June 9, 2024 2

I will have a look within the days.

from reportgenerator.

Malivil avatar Malivil commented on June 9, 2024 2

I appreciate the dialog here and the work you've both done on your respective tools =)

from reportgenerator.

uhafner avatar uhafner commented on June 9, 2024 1

This behavior is "as designed". Nested classes are processed as a part of the parent file.
Otherwise the HTML reports could become bloated with nested and compiler generated classes.

I understand that this makes sense for the user interface, but wouldn't it be more appropriate if the model would retain the original structure and add these nested classes to the parent file? E.g. in JaCoCo reports those nested classes are also shown as direct descendants of the associated file, but they are not removed (i.e. the class in class hierarchy is flattened). Can't you ignore these classes in the HTML reports only?

I added a fix to ignore and skip those method nodes on my side (see jenkinsci/coverage-model#39) but it would be more appropriate if the generated model would retain this information.

from reportgenerator.

uhafner avatar uhafner commented on June 9, 2024 1

No worries, I released a new version of the Jenkins coverage plugin that is more resilient about "errors" during parsing.

from reportgenerator.

danielpalme avatar danielpalme commented on June 9, 2024 1

I decided to not implement the required changes (at least not at the moment).

Reasons:

  • It would require quite a lot of work, as I would have to change all the different parsers.
  • It would be a breaking change for many users. One option could be, that the new behavior is only enabled with an additional command line option, but then only very few users will notice the new option.
  • For many .NET based projects merging coverage report is no longer necessary. If you use Microsoft.CodeCoverage and execute the tests at the solution level, you'll get a single coverage file.
    See also: https://devblogs.microsoft.com/dotnet/whats-new-in-our-code-coverage-tooling/ (section "Auto-Merge for solutions")

from reportgenerator.

danielpalme avatar danielpalme commented on June 9, 2024 1

I just released version 5.2.4. This version includes a new setting (settings:rawMode=true).

The setting disables that coverage data of nested or compiler generated classes is included in the parent class.
This is useful to merge several Cobertura files into a single file, since the original class structure remains untouched.

Limitations:

  • Raw mode is currently only supported for Cobertura files.
  • If you want HTML report and Cobertura output, you should execute ReportGenerator twice:
    • Cobertura: settings:rawMode=true
    • HTML: settings:rawMode=false

You need a PRO license to use the new feature.

Documentation of the new feature:
https://reportgenerator.io/features#rawmode
https://reportgenerator.io/pro

from reportgenerator.

Malivil avatar Malivil commented on June 9, 2024

Possibly related, this happens with nested classes as well.

public static class Outer
{
    public static class InnerFirst
    {
    }

    public static class InnerSecond
    {
    }
}

Will create two entries under "Outer" with the name of ".cctr" and an empty signature

from reportgenerator.

danielpalme avatar danielpalme commented on June 9, 2024

I just had a look at the two problems:

  1. Duplicate Index method

This is the relevant information from coverage.cobertura.txt

<class name="CoverletRepro.TestController" filename="TestController.cs" line-rate="1" branch-rate="1" complexity="1">
  <methods>
    <method name="Index" signature="()" line-rate="1" branch-rate="1" complexity="1">
    ...
    
<class name="CoverletRepro.TestController/&lt;Index&gt;d__1" filename="TestController.cs" line-rate="1" branch-rate="1" complexity="1">
  <methods>
    <method name="MoveNext" signature="()" line-rate="1" branch-rate="1" complexity="1">

Both signature attributes show an empty method signature.
This results in the described output with two methods that look the same.

ReportGenerator does not parse the corresponding source code, it relies on the coverage file.
In this case the result is not perfect, but the input is neither.

  1. Nested classes
    This behavior is "as designed". Nested classes are processed as a part of the parent file.
    Otherwise the HTML reports could become bloated with nested and compiler generated classes.

Methods and/or constructors of nested classes will be listed in the context of the parent class and therefore several entries with the same name and signature can appear. They are not referring to the same code lines though, you can see different <line> elements within those method elements.

from reportgenerator.

Malivil avatar Malivil commented on June 9, 2024

This originally came up because the code coverage plugin I use in Jenkins updated and now errors if there are duplicated entries (See jenkinsci/code-coverage-api-plugin#785).

Your point about the nested classes seems to say this behavior of rejecting duplicate method names is incorrect.

from reportgenerator.

danielpalme avatar danielpalme commented on June 9, 2024

Your point about the nested classes seems to say this behavior of rejecting duplicate method names is incorrect.

"Incorrect" is a bit too hard. I would say, it would be good not to rely on unique names.
There are situations where it can happen (obviously).

from reportgenerator.

danielpalme avatar danielpalme commented on June 9, 2024

@uhafner
You are right, for the Cobertura report it would make sense to retain the original structure.
I will have a look, if I can change the structure. But it will take some time, since this will require some rework and I'm pretty busy at the moment :-)

from reportgenerator.

viceice avatar viceice commented on June 9, 2024

Ms code coverage isn't a solution because of

from reportgenerator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.