One of the projects I have got “A” ratings though all metrics in SonarQube. The only problem: it showed a project size with 0 lines of code. How did this happen?
After checking the logs, I noticed a warning indicator on the project page of SonarQube:
I clicked on the link and got this notice that my project only contains TEST code:
The provided link to the documentation explains the various reasons why this could happen. My project had neither a reference to a test framework nor was it named in such a way that it could be mistaken for a test project. There was also no hint in the log file as to why the mix-up occurred.
Should you run into the same problem, you can add this property group to the *.csproj file for all projects that should be counted:
1 2 3 4 |
<PropertyGroup> <!-- Project is not a test project --> <SonarQubeTestProject>false</SonarQubeTestProject> </PropertyGroup> |
After the next analysis the code in the project was counted in SonarQube and I got a correct rating for the metrics – and a list of items to fix.