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

Fix code coverage reporting of conditions on non-executable lines #2558

Closed
yassin-kammoun-sonarsource opened this issue Apr 12, 2021 · 0 comments · Fixed by #2559
Closed
Assignees
Labels
type: bug Exceptions and blocking issues during analysis
Milestone

Comments

@yassin-kammoun-sonarsource
Copy link
Contributor

yassin-kammoun-sonarsource commented Apr 12, 2021

The community reported an issue about uncovered lines not-shown for conditions in jsx. This problem actually generalises to conditions on non-executable lines regardless of jsx constructs. For the particular case of SonarJS and LCOV coverage engine, SonarQube should highlight uncovered conditions of branches (BRDA) regardless of whether those branches belong to a particular executable line (DA) or not. Otherwise, users will have a hard time identifying at what line a condition is partially covered, especially if the source code happens to be big.

The culprit of the aforementioned issue is SonarJS's LCOV parser on code coverage reporting. For SonarQube to highlight partial coverage, it requires that there is a hit and uncovered condition(s) for a given line. Currently, a line is marked as hit by the LCOV parser only if it is an executable line. We should relax that requirement so that executable lines and non-executable-lines that include conditions are highlighted on SonarQube when it comes to code coverage. In other words, we should add synthetic line hits for BDRAs whose line number don't occur in any DAs.

SonarQube's code coverage reporting API says that line hits should only apply to executable lines. However, after a few experiments, it happens to be safe for non-executable ones as well. Also, it turns out that the JaCoCo coverage importer does exactly what we want to achieve here, i.e. non-executable lines that include conditions are always marked as hit. Discussions with SQ and SL folks led to the conclusion that such a change would not hurt. Beside having the UI red marker, the main impact would lie in the overall coverage since non-executable lines including conditions would then become executable ones.

@yassin-kammoun-sonarsource yassin-kammoun-sonarsource added type: bug Exceptions and blocking issues during analysis coverage labels Apr 12, 2021
@yassin-kammoun-sonarsource yassin-kammoun-sonarsource added this to the 7.4 milestone Apr 12, 2021
@yassin-kammoun-sonarsource yassin-kammoun-sonarsource removed this from the 7.4 milestone Apr 22, 2021
@yassin-kammoun-sonarsource yassin-kammoun-sonarsource changed the title Fix code coverage reporting of conditions in non-executable lines Fix code coverage reporting of conditions on non-executable lines Apr 26, 2021
@saberduck saberduck added this to the 7.4 milestone Oct 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Exceptions and blocking issues during analysis
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants