Sure, there is an API: https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/analysis/package-summary.html <https://www.jacoco.org/jacoco/trunk/doc/api/org/jacoco/core/analysis/package-summary.html>
Please see documentation for usage examples: https://www.jacoco.org/jacoco/trunk/doc/api.html <https://www.jacoco.org/jacoco/trunk/doc/api.html> Regards, -marc > On 2. Oct 2019, at 10:03, [email protected] 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/ > <https://docs.sonarqube.org/latest/extend/executable-lines/>, are already > taken care of by Jacoco. > > I had a look at https://www.jacoco.org/jacoco/trunk/coverage/jacoco.xml > <https://www.jacoco.org/jacoco/trunk/coverage/jacoco.xml> where for example > > <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. > > > On Tuesday, October 1, 2019 at 10:04:37 PM UTC+5:30, Marc R. Hoffmann wrote: > Hi Shubham, > > the Code base of JaCoCo is maintained here: https://github.com/jacoco/jacoco > <https://github.com/jacoco/jacoco> > > https://github.com/SonarSource/sonar-java > <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 > <https://www.jacoco.org/jacoco/trunk/coverage/jacoco.xml> > > Regards, > -marc > > > > We cannot answer questions about >> On 1. Oct 2019, at 11:22, shubh...@ <>gmail.com <http://gmail.com/> wrote: >> >> 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 Github >> <https://github.com/jacoco/jacoco>: >> https://github.com/jacoco/jacoco/issues/935 >> <https://github.com/jacoco/jacoco/issues/935> but didn't get much then >> "marchof <https://github.com/marchof>" asked me to explore more from the >> SonarQube side. >> >> I then raised a question on https://community.sonarsource.com >> <https://community.sonarsource.com/>: >> https://community.sonarsource.com/t/code-coverage-for-the-current-build-versus-the-build-triggered-previous-minus-last-build/14047/10 >> >> <https://community.sonarsource.com/t/code-coverage-for-the-current-build-versus-the-build-triggered-previous-minus-last-build/14047/10> >> >> In order to calculate the "Coverage on new code". >> >> SonarQube does an SCM diff. >> Then it filters the non-executable lines, concept: Executable Lin >> <https://docs.sonarqube.org/latest/extend/executable-lines/>es >> 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 >> <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 >> >> >> >> -- >> 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 jac...@ <>googlegroups.com <http://googlegroups.com/>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/jacoco/911523e3-43f7-4d39-a87a-9ca5affaea20%40googlegroups.com >> >> <https://groups.google.com/d/msgid/jacoco/911523e3-43f7-4d39-a87a-9ca5affaea20%40googlegroups.com?utm_medium=email&utm_source=footer>. > > > -- > 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 [email protected] > <mailto:[email protected]>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/jacoco/ecaefa22-ca8a-47c0-8d0f-013f0569904e%40googlegroups.com > > <https://groups.google.com/d/msgid/jacoco/ecaefa22-ca8a-47c0-8d0f-013f0569904e%40googlegroups.com?utm_medium=email&utm_source=footer>. > <JaocoExcutable.png> -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/0D22064E-D7AB-4CC8-A133-4BC247E28BB0%40mountainminds.com.
