What's the difference between 'lines to cover' and 'uncovered lines'?

I’m using SonarQube Developer Edition 10.1. The docs here have these definitions:

Lines to cover (lines_to_cover ): The number of lines of code that could be covered by unit tests (for example, blank lines or full comments lines are not considered as lines to cover).

Uncovered lines (uncovered_lines ): The number of lines of code that are not covered by unit tests.

So what exactly is the difference? For example, in my new code coverage results for one file SQ reports 48 lines to cover but only 10 uncovered lines! So they’re clearly not being treated as the same.

It would be great if someone could clarify this, please, as I’m struggling to figure out which new lines I should be covering in my unit tests. Unfortunately SQ doesn’t clearly indicate which new lines need covering. It would be great if it could jump to the first line that needs covering and then jump to the next one when you click a ‘next’ or ‘down’ button for example.

HI,

As the docs say, Lines to cover is the total number of lines that could be covered. Consider it: covered_lines + uncovered_lines.

There are both marginal markers and mouseover highlighting to indicate coverage. E.G.:

Thanks for this feedback. We’re reconsidering a lot of things right now & I’ll pass this on.

 
Thx,
Ann

1 Like

Thanks for the reply and for the clarification. Ok, perhaps ‘lines to cover’ should be renamed as it sounded like an imperative to me rather than a description; almost like ‘tests to run’ for example. Or even removed from the coverage sidebar altogether as it’s arguably not that interesting compared to uncovered lines. But if the docs defined lines_to_cover = covered lines + uncovered_lines as you say, that would be helpful. And maybe provide a hovertip with the definition if a user hovers over the words in the sidebar.

I did see the coverage markers and mouseover highlights as you showed, but I still found it tricky to see which lines SQ really wanted me to cover to boost coverage past the critical 80% threshold. Having buttons to click to jump between the required changes (like when diffing code for example) would be really helpful, so thanks for passing that on.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.