Condition Coverage looks off in some cases

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    SonarQube 8.0
    SonarScanner 4.2

  • what are you trying to achieve
    I’ve generated code coverage output using gcovr (with the sonarqube output flag) and imported it into SonarQube. I’m trying to understand the Condition Coverage and how it works. I’ve read and understand the calculation of the metric, but there seem to be cases where I’m not sure why the UI is saying “Partially covered by tests (X of Y conditions)” when its on a line that doesn’t seem to have multiple conditions.

For instance
1 if ( iter != staged_ids.end() )
2 {
3 staged_ids.erase( iter );
4 return true;
5 }

It’s stating that line 3 is partially covered. While I understand that there might be a check internally in that call that checks to see if the ‘iter’ exists, I don’t know if that should count against the consumer’s condition coverage count. Especially since the code surrounding it prevents that from happening.

In another case, there’s a class that’s been defined:
1 class foo()
2 {
3 // many methods
4 };

And sonarqube says line 1 is partially covered?

I’m just trying to understand condition coverage works in these cases. Any help would be greatly appreciated. Thank you!

Hi @leisinmr,

we simply import the given report, to have an idea of how it works you can check manually the content of gcov files and/or generate an html report from the gcov files and double check with what shown in SonarQube.