0

I have a SonarQube 5.6 installation, using C/C++ plugin 3.12 to analyse our project. I have generated coverage results (gcov), but so far only for one of the application C files. The coverage is at 98.3%. When analysing the whole project that application coverage results gets 'imported' and I can trace them on the web interface.

On the top-level Code page the folder containing that file shows then 98.3%, which in my view is not correct, since for all the other C files no coverage is yet available. I've tried to show that in the following series of snapshots:

(1) Top-level Code Tree: Top-level Code Tree

(2) Going down the 'Implementation' tree: enter image description here

(3) Going down the 'Implementation/ComponentTemplate' tree: enter image description here

(4) Going down the 'Implementation/ComponentTemplate/code' tree: enter image description here

EXMPL.c has only (4):113 Lines of Code. Compared to the total Lines of Code of 'Implementation' (4):61k, this is somewhere of about 0.2% only. The coverage for EXMPL.c of 98.3% in (1) is then wrong !

My project consists of several applications, EXMPL is one - the smallest one - of all my applications within the project. So I have to produce separate coverage results for each application and to 'import' them seperately into sonar. Coverage result files are therefore located in different folders.

Maybe that project structure or the 'incomplete import' of coverage results is the cause of the 'wrong' coverage measures, but so far, I have not found any useful information on how sonar is handling provided gcov coverage measures.

Any help or information will be appriciated. Thanks

Community
  • 1
  • 1
MlaKe
  • 39
  • 2
  • 9

1 Answers1

1

Your second guess is right: the incomplete import of coverage results is what's skewing the numbers. Lines that aren't included in the coverage report aren't included in the coverage calculations. Since the current coverage report includes only one file that's 93% covered, all the numbers are based on that.

G. Ann - SonarSource Team
  • 22,346
  • 4
  • 40
  • 76
  • Mmmh, that's not very helpful. Isn't there a way, to tell something like '_assume default coverage is 0% for sources without corresponding .gcov files_' ? – MlaKe Sep 19 '16 at 13:29
  • This is currently available on a language-by-language basis. We've got a broader solution in the pipe, but I can't give you an ETA. :-( – G. Ann - SonarSource Team Sep 19 '16 at 13:59
  • Ok, as a workaround I'll place '_empty_' .gcov files in each folder. Where tests are performed and coverage generated those '_empty_' files will be overwritten. That's not nice, but I'll accept it. Thanks – MlaKe Sep 19 '16 at 14:03
  • Those 'empty' files need to enumerate the files (lines?) in the directory to get the result you want. – G. Ann - SonarSource Team Sep 19 '16 at 14:12
  • :-/ That's correct, unfortunately. So I've no workaround and have to wait for your solution. – MlaKe Sep 19 '16 at 14:34