SonarQube C#
  1. SonarQube C#
  2. SONARCS-196

O% test coverage on codeless interfaces

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.1
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      0

      Description

      On interfaces containing only method signatures, the "code coverage decorator" still insert coverage metrics that triggers violations when using the SQALE plugin.
      Global test coverage is pretty good but the useless sqle coverage violation are annoying.

        Activity

        Hide
        Alexandre Victoor added a comment - - edited

        In CoverageDecorator , instead of having

               context.saveMeasure(CoreMetrics.COVERAGE, 0.0);
              context.saveMeasure(CoreMetrics.LINE_COVERAGE, 0.0);
              // for LINES_TO_COVER and UNCOVERED_LINES, we use NCLOC and STATEMENTS as an approximation
              Measure ncloc = context.getMeasure(CoreMetrics.NCLOC);
              if (ncloc != null) {
                Measure sts = context.getMeasure(CoreMetrics.STATEMENTS);
                double lines = Math.min(ncloc.getValue(), sts.getValue());
                if (lines > 0d) {
                  context.saveMeasure(CoreMetrics.LINES_TO_COVER, lines);
                  context.saveMeasure(CoreMetrics.UNCOVERED_LINES, lines);
                }
              }
        

        we should have

              // for LINES_TO_COVER and UNCOVERED_LINES, we use NCLOC and STATEMENTS as an approximation
              Measure ncloc = context.getMeasure(CoreMetrics.NCLOC);
              if (ncloc != null) {
                Measure sts = context.getMeasure(CoreMetrics.STATEMENTS);
                double lines = Math.min(ncloc.getValue(), sts.getValue());
                if (lines > 0d) {
                  context.saveMeasure(CoreMetrics.LINES_TO_COVER, lines);
                  context.saveMeasure(CoreMetrics.UNCOVERED_LINES, lines);
                  context.saveMeasure(CoreMetrics.COVERAGE, 0.0);
                  context.saveMeasure(CoreMetrics.LINE_COVERAGE, 0.0);
                }
              }
        
        Show
        Alexandre Victoor added a comment - - edited In CoverageDecorator , instead of having context.saveMeasure(CoreMetrics.COVERAGE, 0.0); context.saveMeasure(CoreMetrics.LINE_COVERAGE, 0.0); // for LINES_TO_COVER and UNCOVERED_LINES, we use NCLOC and STATEMENTS as an approximation Measure ncloc = context.getMeasure(CoreMetrics.NCLOC); if (ncloc != null ) { Measure sts = context.getMeasure(CoreMetrics.STATEMENTS); double lines = Math .min(ncloc.getValue(), sts.getValue()); if (lines > 0d) { context.saveMeasure(CoreMetrics.LINES_TO_COVER, lines); context.saveMeasure(CoreMetrics.UNCOVERED_LINES, lines); } } we should have // for LINES_TO_COVER and UNCOVERED_LINES, we use NCLOC and STATEMENTS as an approximation Measure ncloc = context.getMeasure(CoreMetrics.NCLOC); if (ncloc != null ) { Measure sts = context.getMeasure(CoreMetrics.STATEMENTS); double lines = Math .min(ncloc.getValue(), sts.getValue()); if (lines > 0d) { context.saveMeasure(CoreMetrics.LINES_TO_COVER, lines); context.saveMeasure(CoreMetrics.UNCOVERED_LINES, lines); context.saveMeasure(CoreMetrics.COVERAGE, 0.0); context.saveMeasure(CoreMetrics.LINE_COVERAGE, 0.0); } }

          People

          • Assignee:
            Alexandre Victoor
            Reporter:
            Alexandre Victoor
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: