Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Clover.xml : Number of covered lines

Hello

When I run tests, I get a clover.xml file that contains tags and attributes like this:

<metrics conditionals="664" methods="117" classes="13" files="9" packages="1" coveredstatements="1554" complexity="710" loc="3620" ncloc="3203" coveredmethods="105" coveredconditionals="479" statements="1989" coveredelements="2138" elements="2770"/>

Among the attributes, we find methods and coveredmethods, statements and coveredstatements, ...
I'm interested in number of code lines, and the number of covered code lines.
Is there a way to have them in clover.xml, preferably in the same metrics tag?

Thanks in advance..

2 answers

1 accepted

1 vote
Answer accepted

loc="3620" is the number for Lines Of Code.

I think that ncloc="3203" is the number for Non-Comment Lines of Code as per https://confluence.atlassian.com/display/CLOVER/clover-report

Actually there is no point in "Covered Lines of Code" number. "Covered Statements" is very well describing the coverage.

Cheers,
Jacek

I see.
But can you please further explain why "cover lines of code" number is not a good metric for coverage? An example would be very appreciated.
Thank you.

I see.
But can you please further explain why "cover lines of code" number is not a good metric for coverage? An example would be very appreciated.
Thank you.

There are 3620 lines of code. Comments and empty lines cannot be covered so we can only consider lines with the real code to cover.

You have 1989 statements. Some of them probably span multiple lines so let's assume there are 2000 lines of code containing statements.

Next let's assume that all your code is covered (all 1989 statemetns and thus all 2000 lines). It means that your code is fully covered (1989 statements in total / 1989 statements covered = 100%). This is very good existing metric.

On the other hand there are: 2000 lines with code covered / 3620 lines in total = 55%. If you add more comments or empty lines (e.g. licensing information) then the number will drop below 55% while still all your code will be covered.

This 55% simply says nothing.

In order to make it reasonable we would need to find "number of lines containing statements" and compare with "number of covered lines containing statements" to get meaningfull 100% - but this is actually duplicate of what we have now: number of statements and number of covered statements.

Does this answer your question?

Cheers,
Jacek

Yes. Thank you so much :)

Hi Raphael,

doesn't "loc=3620" represent your (covered) lines of code and "ncloc3203" the uncovered LOC?

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Opsgenie

Investigate deployment-related incidents with Bamboo and Opsgenie together

Back in April of last year one of the major product announcements from Opsgenie was the launch of the Incident investigation view which created a deep connection between Bitbucket and Opsgenie, empow...

110 views 1 4
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you