如何使Sonarqube从覆盖范围内排除.NET(C#)项目 [英] How to make Sonarqube exclude a .NET (C#) project from coverage measures

查看:464
本文介绍了如何使Sonarqube从覆盖范围内排除.NET(C#)项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Sonarqube通过在 sonar.coverage.exclusions 键中添加模式,可以将单个文件排除在代码范围之外.通过在UI中甚至通过指定 SonarQubeSetting 元素将其添加到.csproj文件中,都可以在项目级别完成此操作.即

Sonarqube allows for individual files to be excluded from code coverage by adding patterns in the sonar.coverage.exclusions key. This can be done on a project level by adding them in the UI and even in a .csproj file by specifying a SonarQubeSetting element. I.e.

<SonarQubeSetting Include="sonar.coverage.exclusions"> <Value>**/*.cs</Value> </SonarQubeSetting>

<SonarQubeSetting Include="sonar.coverage.exclusions"> <Value>**/*.cs</Value> </SonarQubeSetting>

但是,这两种方法似乎都不起作用.不按照SonarQube 文档中的指定使用模式预期的结果.我也知道 SonarQubeExclude MSBuild属性的存在,但是我不想走这条路,因为它将把我的项目排除在所有其他分析之外.

However, both of these approaches don't seem to work. Playing with the patterns, as specified in the SonarQube documentation doesn't provide the desired result. I'm also aware of the existence of the SonarQubeExclude MSBuild property, but I don't want to go down that path as it would exclude my project from all other analysis.

我是否还有另一种失踪的可能性?还是根本不可能从代码覆盖率中排除项目中的所有类?

Is there another possibility that I'm missing? Or is it simply not possible to exclude all of the classes within a project from code coverage?

推荐答案

没有足够的代表评论,但是如果您在此处应用两个答案,则只需添加:

Not enough rep to comment, but if you apply both answers here, you can simply add:

<PropertyGroup>
    <!-- Exclude the project from analysis -->
    <SonarQubeExclude>true</SonarQubeExclude>
</PropertyGroup>

在.csproj文件中

排除整个项目,而不是单个文件,或者依赖声纳过滤器.

in the .csproj file to exclude the entire project instead of individual files, or relying on sonarqube filters.

这篇关于如何使Sonarqube从覆盖范围内排除.NET(C#)项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆