galexandre / sonar-cobertura

Cobertura plugin for SonarQube
GNU General Public License v3.0
30 stars 26 forks source link

Plugin is marking excluded classes as uncovered #24

Open rschaeferhig opened 5 years ago

rschaeferhig commented 5 years ago

We just upgraded from an older version of the plugin running in Sonarqube 5.6.6 to the latest running in 6.7. We have a number of Maven builds that excluded classes from Cobertura. The developers report that prior to the Sonarqube/plugin upgrade the excluded classes were not counted/reported in Sonarqube. After the upgrade the classes are showing as uncovered.

It appears that in earlier versions a class in the source code not reported in Cobertura was ignored in Sonarqube. Was there a change such that a class defined in the code that was not reported at all in coverage.xml now shows as uncovered?

galexandre commented 5 years ago

Hi,

As far as I remember the refactor performed shouldn't have change the behaviour of that. How do you exclude the class?

Regards,

rschaeferhig commented 5 years ago

They do something like this in their POM

<plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>cobertura-maven-plugin</artifactId>
        <configuration>
          <instrumentation>
            <!-- Ignore basic getters/setters, don't count in code coverage -->
            <ignoreTrivial>true</ignoreTrivial>
            <!-- Ignore basic logging statement, don't count in code coverage -->
            <ignores>
              <ignore>org.apache.log4j.*</ignore>
              <ignore>org.slf4j.*</ignore>
              <ignore>org.apache.logging.*</ignore>
            </ignores>
            <!-- Ignore methods annotated as being covered in Integration tests -->
            <ignoreMethodAnnotation>com.thehartford.sp.common.service.IntegrationTested</ignoreMethodAnnotation>
            <!-- Ignore methods annotated as not able to cover in test, such as certain no-op and empty methods required by implemented interfaces -->
            <ignoreMethodAnnotation>com.thehartford.sp.common.util.CoverageIgnore</ignoreMethodAnnotation>
            <excludes>
              <exclude>com/thehartford/venture/entities/**/Abstract*.class</exclude>
              <exclude>com/thehartford/venture/entities/**/*DAO.class</exclude>
              <exclude>com/thehartford/venture/entities/**/*VwId.class</exclude>
              <exclude>com/thehartford/venture/entities/filters/EntityManagerHelper.class</exclude>
              <exclude>com/thehartford/venture/**/package-info.class</exclude>
              <exclude>com/thehartford/venture/dataServices/CommonReportService.class</exclude>
            </excludes>
          </instrumentation>
        </configuration>
      </plugin>

Which excludes those classes from Cobertura. Prior to the upgrade they wouldn't show up at all in Sonarqube under Coverage. Now they show up as zero coverage.

rschaeferhig commented 5 years ago

Coverage from Sonarqube. I don't have prior since we converted and I didn't keep the old site. coverage

galexandre commented 5 years ago

Okay I see. I didn't test this scenario to be honest. I am trying to find any changes that would impact the behaviour in te merge request (https://github.com/galexandre/sonar-cobertura/pull/22/files)

rschaeferhig commented 5 years ago

Could be that it's not something you did in the PR but something that changed in Sonarqube with 6.x that the plugin doesn't account for...

galexandre commented 5 years ago

In this case you need to open a ticket in the Sonar forum.

rschaeferhig commented 5 years ago

If it was a change in Sonarqube that needs to be accounted for in the plugin then wouldn't it be a plugin change, not a Sonar change? Missed use case?

galexandre commented 5 years ago

As I said I didn't test the use case. I will have a look in Sonar documentation