Code coverage section is gone

In SonarCloud, when I send scan results with sonar.coverage.exclusions="/." set via the command line, the code coverage section disappears, which is what I wanted. After pushing results now without this line, the code coverage section does not reappear even when I push JaCoCo test coverage reports. In the past, I was able to test with "/." and removing it always had the section reappear, and now that I need to show the code coverage section, it doesn’t. I’ve checked the configuration and nothing is set via the UI. The only thing that would likely work is if I recreate the repo in SonarCloud, but I rather not. Can anyone tell me why this section is not appearing? You can have a look here

Hello Steven and welcome!

From what I can see in your project only an home.html file is currently analyzed (and the java test file), so your sources configuration is probably wrong. If you want to get the coverage on your java files then you should add them to the sources that are analyzed by SonarCloud.

I’m not sure if this is the case here. My current setup generates the correct report in the default locations that are required by SonarCloud and all files are analyzed for issues and quality stuff.

The only extra thing I did was add sonar.sources to my POM file to tell Sonar to scan my html files for issues as well as what was recommend by a note in SonarCloud. Also, I have another project which has the coverage section in SonarCloud that I am missing because I never set this to exclude/hide.

Yesterday, I did some more tests with a new repo, and I noticed something. Not to long ago, I always had the coverage section for every new project in SonarCloud even when I wasn’t sending reports to it like the link above. Then, I started doing an exclude all like in my first post, and that section would disappear until I removed that. However, yesterday, I created a new project as a test, but there was no coverage section, so something here has changed.

Can you tell me what I need to change in my POM to make the coverage appear? From what I can see from other examples online, my POM configuration is the same.

From your project in your first post the reason why you don’t see coverage if because you only analyse an html file, your coverage report is probably correct but since there is no file that relate to it on the system you don’t have any coverage showing.

You can see this when you go to the measures page of your project:

On the screenshot we can see that the only file that is analyzed is this html file.

And this seems to match what you have in your pom here:

So you should change this line in your pom to also include all you java files.

Thanks, you are correct since the beginning. Where I went wrong was to change the default for sonar.sources by trying to add the html as the sonar note suggested, which later excluded what I needed. I’ve now done other tests playing with this property, and I was able to see the coverage results section. Thanks for your help! Stupid mistake on my part.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.