You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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
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
BDRA
s whose line number don't occur in anyDA
s.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.
The text was updated successfully, but these errors were encountered: