Issue with CodeCoverage and matching to its original source

sonarqube
(Ian Rowlands) #1

I’m using the Gradle sonarqube version 2.7 plugin. Ever since I upgraded to 2.7 (I was using 2.6.2 before that) I noticed the code coverage has dropped despite the code remaining the same. In particular, it said some of my code was not covered when in fact there are tests for that code.

(If it matters, I was running SonarQube 7.0 - I just upgraded to 7.7 but the behaviour remains).

In addition, I started getting errors during the running of the plugin saying

the class ‘X’ could not be matched to its original source file. It might be a dynamically generated class

All of the classes it mentions are actually part of the projects being analysed, so the source files are actually there.

This is a multi-module Gradle project. Each sub-project is in a “standard” layout (i.e src/main/java for the main code, src/main/test for the test code).

In the top-level build.gradle file, I have the properties “sonar.cpd.exclusions” and “sonar.exclusions” defined. Apart from that, there’s no other special configuration.

Any ideas on why my code coverage has dropped suddenly and no longer picking up some tests running over some code? Is it related to the “could not be matched” problem? Is there anything else I need to look at?

Thanks,

Ian

2 Likes
(Ian Rowlands) #3

Any ideas as to why this suddenly changed? Is there anything I can run to help diagnose this? The output from SonarQube is simply wrong - the source code does in fact exist, within the project being analysed.

(Janos Gyerik) #5

Are you absolutely sure that this change of plugin version caused the drop in coverage? It’s easy to verify: run another analysis using 2.6.2 and keeping everything else the same. We’re not aware of anything in this release that could have such effect. We suspect there are other changes in your project that caused this. Please do this test first before we continue to investigate.

I believe this message comes from the findbugs plugin, which is not managed by us. This looks like a related ticket, and this and this thread could be possible solutions.