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

Only the first assembly specified via 'sonar.gallio.coverage.excludes' is actually excluded

    Details

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

      Description

      Issue SONARPLUGINS-1417 added code to GallioCommandBuilder to exclude any assemblies specified via the comma-separated config property 'sonar.gallio.coverage.excludes' from the NCover command call using the //ias command line argument.

      This is great, but the way this property is retrieved in org.sonar.plugins.csharp.gallio.GallioSensor.analyse() means that only the first assembly specified via the property will actually be considered in the NCover excludes:

      builder.setCoverageExcludes(configuration
      .getString(GallioConstants.COVERAGE_EXCLUDES_KEY, GallioConstants.COVERAGE_EXCLUDES_DEFVALUE));

      (I suspect that the same applies to PartCover, and in 1.2 also OpenCover, but I haven't tested it.)

      The problem is that getString() returns only the first token in the comma-separated list. In the following scenario:

      sonar.gallio.coverage.excludes=Assembly1,Assembly3,Assembly3

      only Assembly1 would be actually excluded.

      One possible solution would be to read and concatenate all tokens using getStringArray(), for example:

      String[] coverageExcludesArray = configuration.getStringArray(GallioConstants.COVERAGE_EXCLUDES_KEY);
      String coverageExcludesString = "";
      for (String exclude : coverageExcludesArray) {
      if (!coverageExcludesString.isEmpty())

      { coverageExcludesString += ","; }

      coverageExcludesString += exclude;
      }
      builder.setCoverageExcludes(coverageExcludesString);

      It would probably be cleaner though to change the interface of GallioCommandBuilder.setCoverageExcludes() to take an array of excludes instead of a single String, but that would require more extensive code changes.

        Activity

        Hide
        Alexandre Victoor added a comment -

        Fixed
        Also files from excluded assemblies do not have any coverage data anymore

        Show
        Alexandre Victoor added a comment - Fixed Also files from excluded assemblies do not have any coverage data anymore
        Hide
        Fabrice Bellingard added a comment -

        Tested.

        Show
        Fabrice Bellingard added a comment - Tested.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: