SonarQube version: 9.9 LTS
Installed: zip
Issue:
Users of our SonarQube instance have added the [ExcludeFromCodeCoverage] attribute to a method. SonarQube is excluding most of the lines of that specific method from coverage, but a few are marked as “Not Covered”.
I am aware that SQ is depend on the code coverage tool that is used. However, when i download the code coverage results i do see that that method is excluded.
Example:
Option 1: Code coverage results in Visual Studio when method is not excluded:
Option 2: Code coverage results in Visual Studio when method is excluded with the ExcludeFromCodeCoverage attribute:
As you can see, that specific method is no longer included.
In SonarQube we can see:
Option 1:
Here we see that the whole method is not covered, working as expected.
Option 2:
Here we can see that the method is mostly excluded, except for a few lines of code.
This is not what i would expect when i look at the code coverage results i opened in Visual Studio.
Question
Why are 5 lines shown as not covered despite the rest of the method being excluded from coverage?