What is the difference between code coverage and line coverage in sonar

code-coverage, sonarqube

Solution

Coverage is a subtle ;-) mix of the line and the branch coverage.

You can find the formula on our metric description page:

coverage = (CT + CF + LC)/(2*B + EL)
 
where
 
CT - branches that evaluated to "true" at least once
CF - branches that evaluated to "false" at least once
LC - lines covered (lines_to_cover - uncovered_lines)
 
B - total number of branches (2*B = conditions_to_cover)
EL - total number of executable lines (lines_to_cover)

Problem

I know what the difference is between line and branch coverage, but what is the difference between code coverage and line coverage? Is the former instruction coverage?

Original source