Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-75295

Cyclomatic complexity is lost when reports are merged

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • coverage-plugin
    • None
    • Jenkins 2.492.1
      Coverage Plugin Version 1.16.1

      .NET SDK 8.0.309
      coverlet.collector 6.0.4

      I have a C# project that is built and tested for two target frameworks: net472 and net8.0. The test runs use the "coverlet.collector" package to output code coverage results in Cobertura format. So there is one Cobertura XML file for net472 and another for net8.0. Jenkinsfile runs the recordCoverage step to read those files.

      If I use one recordCoverage step for net472 and another for net8.0, then Jenkins nicely shows both coverage reports, with cyclomatic complexity for each source file. The steps must specify the id parameter so that Jenkins can distinguish the reports from each other.

      However, if I use a shared recordCoverage step that reads both XML files, so that Jenkins merges the coverage reports, then the "Cyclomatic Complexity" tab lists only one C# source file. That source file contains a #if !NET6_0_OR_GREATER directive so that the source code in it is compiled only for net472 and not for net8.0. The "Files" tab shows a table in which the "Complexity", "Max. Complexity", and "Complexity / LOC" fields are zero for all other source files. In the "coverage.xml" file in the per-build directory in the Jenkins controller, only the classes and methods defined in that one file have any <complexity> elements.

      It thus seems that the merging of coverage results loses the complexity measurements of those types and members that have complexity measurements in more than one Cobertura XML file. I don't know whether this problem is specific to Cobertura.

      "Code Coverage - Messages" doesn't show any warnings. It shows a note "Reference build has no action for ID 'coverage'", because the reference build instead used coverage IDs "coverage_net472" and "coverage_net8.0".

            drulli Ulli Hafner
            kon Kalle Niemitalo
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: