Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor CxxFileLinesVisitorTest #1426

Merged
merged 3 commits into from
Mar 10, 2018
Merged

Conversation

Bertk
Copy link
Contributor

@Bertk Bertk commented Feb 24, 2018

  • only one assert per test
  • add constexpr in test file "ncloc.cc"

This change is Reviewable

- only one assert per test
- add constexpr in test file "ncloc.cc"
- show hits and condition per line
- remove obsolete test
- conditional coverage is not supported with Microsoft coverage data
@Bertk Bertk requested a review from guwirth February 24, 2018 14:23
@Bertk Bertk self-assigned this Feb 24, 2018
@Bertk
Copy link
Contributor Author

Bertk commented Feb 24, 2018

Solves issue #1425

@@ -122,7 +119,6 @@ private static void collectRangeMeasures(SMInputCursor function, Map<String, Cov
coverageData.put(sourceId, builder);
}

builder.setConditions(startLine - 1, conditions, coveredConditions);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Bertk don't understand why this is no more needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are 2 issues with this line:

  • The calculation startLine - 1 creates measures for wrong code lines
  • Microsoft coverage tool only provides block coverage but not branch coverage (selection statements). The indicator for partial covered condition cannot be set for the relevant code line but only for the code block and the code metric shows more conditions for a source file than conditions exists in the file itself.

A compromise is to remove the calculation and set condition for every block but this is a different way Visual Studio does it and should be avoided.

motorcontroller-coverage

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The solution with the compromise produces this output:
partial-covered-block

motorcontroller-measuredetails

@guwirth
Copy link
Collaborator

guwirth commented Mar 7, 2018

@Bertk does this still fit to description in rdwiki https://github.com/SonarOpenCommunity/sonar-cxx/wiki/Get-code-coverage-metrics?

@Bertk
Copy link
Contributor Author

Bertk commented Mar 7, 2018

@guwirth I updated the page and removed the invalid parts.

@guwirth guwirth merged commit c7a37ad into SonarOpenCommunity:master Mar 10, 2018
@Bertk Bertk deleted the coverage branch March 11, 2018 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants