which versions are you using: SonarQube Developer Edition 9.9.0.65466
how is SonarQube deployed: Docker
what are you trying to achieve: get accurate coverage metrics that skip comments nested in the function body
what have you tried so far to achieve this: nothing, as those comments cannot be excluded or moved on the top of the function
Description of a problem:
If there are comments nested in the function body, above the uncovered lines, those will be counted as uncovered lines, so eventually, those are considered by Sonar as uncovered code that affects the final coverage metric. However, as soon as the real code line is covered, coverage metrics are accurately provided, ignoring comments during counting (or considering them as covered). Do I understand correctly, that If I have 98 lines of nested comments out of 100 (2 lines of actual code), I will get 2% of coverage?
SonarQube figures out what lines can be covered by tests based on the reports that were generated by your coverage tool. If your report says those lines can be covered… you probably want to raise an issue with that tool. SonarQube just reads the report.
Nope. @rkrisztian hasn’t come back with a reproducer. If you can come back with one (and details about your setup, like what SonarQube verison you’re using), that would help us investigate!