问题
I have set up a local SonarQube 5.1.1 server. I have also installed the C# plugin (version 4.1), as well as the MSBuild runner (version 1.0). I then performed two separate runs on the .NET codebase for the project I am currently working on:
- Using sonar-runner and the C# plugin
- Using the MSBuild runner
Both runs were made through the CLI. However, the runs yielded very different results. Here is an example: In the first run SonarQube calculated the number of code lines to be roughly 956 000, while in the second run it was calculated to be "only" about 434 000. I then did some digging, and it seems like the latter skips some auto-generated files. These files/classes were generated by an old, internally developed ORM tool.
I thought that unless specified otherwise - by using include/exclude patterns - the MSBuild SonarQube runner would analyse every single .cs file in a given project, but apparently that is not the case.
Has anyone experienced the same "problem", and does anyone know what kind of auto-generated files that will be automatically excluded from an analysis?
回答1:
I have found some information in the Sonar .NET documentation, which states, among other things, states that:
"Certain types of project will automatically be excluded from analysis. For example, Microsoft Fakes generates additional projects during build. These auto-generated projects will not be analysed."
and
"Files that are generated by custom tools within Visual Studio are automatically excluded from analysis, such as the xxx.Designer.cs file generated from a .resx file:"
I assume that our internal ORM tool falls into the latter category. Thus, that explains why those files are being excluded from the analysis.
来源:https://stackoverflow.com/questions/31962814/msbuild-sonarqube-runner-skipping-auto-generated-files