问题描述
我已经设置了本地 SonarQube 5.1.1 服务器.我还安装了 C# 插件(4.1 版)以及 MSBuild 运行程序(1.0 版).然后,我在 .NET 代码库上为我目前正在从事的项目执行了两次单独的运行:
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:
- 使用 sonar-runner 和 C# 插件
- 使用 MSBuild 运行器
两次运行都是通过 CLI 进行的.然而,运行产生了非常不同的结果.这是一个例子:在第一次运行中,SonarQube 计算出的代码行数大约为 956 000,而在第二次运行中,它被计算为仅"大约 434 000.然后我做了一些挖掘,看起来像后者跳过一些自动生成的文件.这些文件/类是由内部开发的旧 ORM 工具生成的.
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.
我认为除非另有说明 - 通过使用包含/排除模式 - MSBuild SonarQube 运行器将分析给定项目中的每个单个 .cs 文件,但显然情况并非如此.
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?
推荐答案
我在Sonar .NET 文档,其中指出:
某些类型的项目将自动被排除在分析之外.例如,Microsoft Fakes 在构建期间会生成其他项目.这些自动生成的项目将不会被分析."
和
"由 Visual Studio 中的自定义工具生成的文件会自动排除在分析之外,例如从 .resx 文件生成的 xxx.Designer.cs 文件:"
我假设我们的内部 ORM 工具属于后一类.因此,这就解释了为什么这些文件被排除在分析之外.
I assume that our internal ORM tool falls into the latter category. Thus, that explains why those files are being excluded from the analysis.
这篇关于MSBuild SonarQube 跑步者跳过自动生成的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!