Jacoco SonarQube Executable Lines Logic

37 views
Skip to first unread message

shubh...@gmail.com

unread,
Oct 1, 2019, 5:22:35 AM10/1/19
to JaCoCo and EclEmma Users
Hi Team,

We are trying to understand how the "Coverage on new code" is calculated in the SonarQube along with Jacoco.

I have raised an issue earlier in the Jacoco Githubhttps://github.com/jacoco/jacoco/issues/935 but didn't get much then "marchof" asked me to explore more from the SonarQube side.


In order to calculate the "Coverage on new code".

  1. SonarQube does an SCM diff.
  2. Then it filters the non-executable lines, concept: Executable Lines
  3. Then it calculates the line covered/ actual coverable lines.

I am interested to know where is this logic written for flagging the code lines as "Executable/Non-Executable Line" is it in https://github.com/SonarSource/sonar-java.

Also, is it written by "Jacoco Devs" or by the "SonarQube Devs"?

I want to bring that logic out of "SonarQube" and use it in some of my use cases along with Jacoco.

Thanks,
Shubham


Marc Hoffmann

unread,
Oct 1, 2019, 12:34:37 PM10/1/19
to jac...@googlegroups.com
Hi Shubham,

the Code base of JaCoCo is maintained here: https://github.com/jacoco/jacoco

https://github.com/SonarSource/sonar-java is maintained by SonarSource.

 am interested to know where is this logic written for flagging the code lines as "Executable/Non-Executable Line”

Actually JaCoCo calculates this for you. Have a look e.g. at the XML report generated by JaCoCo. You will see the execution status of every single line. For example: https://www.jacoco.org/jacoco/trunk/coverage/jacoco.xml

Regards,
-marc



We cannot answer questions about 
--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/911523e3-43f7-4d39-a87a-9ca5affaea20%40googlegroups.com.

shubh...@gmail.com

unread,
Oct 2, 2019, 4:03:28 AM10/2/19
to JaCoCo and EclEmma Users
Thank Marc for replying here,

So, Jacoco knows which line is coverable or not.

And cases, as mentioned in https://docs.sonarqube.org/latest/extend/executable-lines/, are already taken care of by Jacoco.


JaocoExcutable.png



ExecutionDataClient.java has only 44, 45, 49, 50, 52, 54, 55, 58, 59, 60, 63, 64, and 65 are the actual COVERABLE lines among all the lines in that file, right?

Rest lines don't contribute to Coverage as they are "non-executable" code like "{}", "imports", "declaration", right?

My use case here is I have 2 jacoco reports one from last month and one of the present dates and I know the SCM diff b/w the two versions of code. I want to now know what's the delta code covered and don't want to consider the "non-executable" lines as it will show wrong values.

So, is there any specific place/API/report which directly gives the information as the above picture gives me instead of parsing the XML and then doing the calculations.
To unsubscribe from this group and stop receiving emails from it, send an email to jac...@googlegroups.com.

Marc Hoffmann

unread,
Oct 2, 2019, 5:06:38 AM10/2/19
to JaCoCo and EclEmma Users
On 2. Oct 2019, at 10:03, shubh...@gmail.com wrote:

Thank Marc for replying here,

So, Jacoco knows which line is coverable or not.

And cases, as mentioned in https://docs.sonarqube.org/latest/extend/executable-lines/, are already taken care of by Jacoco.


To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/ecaefa22-ca8a-47c0-8d0f-013f0569904e%40googlegroups.com.
<JaocoExcutable.png>

Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages