Uploaded image for project: 'Bamboo Data Center'
  1. Bamboo Data Center
  2. BAM-13813

NCover "Significant code changes" displays percentage incorrecly

    XMLWordPrintable

Details

    Description

      https://bitbucket.org/atlassian/bamboo-dotnet-plugin

      Problem:

      Percentage value for lineCoverage and delta is 100x times smaller than it should be:

      Cause:

      // com.atlassian.bamboo.plugin.dotnet.ncover.NCoverReportParser
      //line coverage is visited/total = [0.0, 1.0]
      
       Double total = (Double) node.selectObject("count(./method/seqpnt)");
                  Double visited = (Double) node.selectObject("count(./method/seqpnt[not(@vc=0 or @visitcount=0)])");
                  buffer.append(nameAttribute.getStringValue()).append(',');
                  buffer.append(visited / total).append(
                          NCoverBuildProcessor.LINE_SEPARATOR);
      										
      // com.atlassian.bamboo.plugin.dotnet.ncover.NCoverBuildProcessorServer
      // coverageInfoList contains NumberUtils.stringToDouble(lineRate)								
      
                  if (!difference.equals(0.0D))
                      coverageInfoList
                              .add(new NCoverCoverageInformation(className,
                                      NumberUtils.stringToDouble(lineRate), difference));					
      
      // com.atlassian.bamboo.plugin.dotnet.ncover.ViewNCoverBuildResults
      // lineRate and delta is not multiplied by 100 to get [0..100] percentage range
      
      					Double lineRate = NumberUtils.stringToDouble(tokenizer.nextToken());
      					Double delta = NumberUtils.stringToDouble(tokenizer.nextToken());
      					//lineRate = NumberUtils.round(lineRate * 100, 2);
      					//delta = NumberUtils.round(delta * 100, 2);
      					coverageChanges.add(new NCoverCoverageInformation(
      							className, lineRate, delta));
      							
      // com/atlassian/bamboo/plugin/dotnet/ncover/viewNCoverResult.ftl							
      // it takes values "as is"
      
      [#list coverageChanges as classInformation]
                  <li>${classInformation.className}: ${classInformation.lineRate}% coverage (
                  [#if classInformation.delta < 0]
                  <span style="color:#cc3333;">
                  [#else]
                  <span style="color:#339933;">
      			[/#if]
                  ${classInformation.delta}%
                  </span>
                  )
                  </li>
                  [/#list]
      

      Fix:

      Either multiply values by 100 in FTL template or keep them already multiplied in NCOVER_RESULT_CONTENTS CSV.

      Attachments

        Activity

          People

            mparfianowicz Marek Parfianowicz
            mparfianowicz Marek Parfianowicz
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: