MSBuild SonarQube runner skipping auto-generated files?

帅比萌擦擦* 提交于 2019-12-22 17:39:15

问题


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:

  1. Using sonar-runner and the C# plugin
  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!