如何为测试项目禁用SonarLint [英] How to disable SonarLint for test projects

查看:93
本文介绍了如何为测试项目禁用SonarLint的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VS 2015中安装了SonarLint,它看起来像是一个很好的扩展,具有很大的潜力.

目前,扩展程序还正在分析我的测试项目并提供警告.如何禁用对特定(测试)项目的检查?

更新它不是关于在SonarQube中禁用特定的Sonar规则或项目,而是关于Visual Studio扩展SonarLint.

解决方案

在Visual Studio中,打开项目,然后深入参考"部分.选择编辑活动规则集:

在打开的屏幕中,选择/取消选择特定项目所需的规则.然后点击保存.这很可能会在您的项目中创建一个新的 .ruleset 文件,并指示Roslyn使用该文件而不是标准集.

结果是使用< CodeAnalysisRuleSet> 标记更新了项目文件,如下所示:

 < CodeAnalysisRuleSet> UnitTests.Core.ruleset</CodeAnalysisRuleSet> 

您还可以使用添加新文件向导并选择代码分析规则集"选项:

然后从分析"菜单中选择配置解决方案的代码分析",可以从此处选择新添加的规则集并将其分配给所需的项目:

I installed SonarLint in VS 2015 and it looks like a great extension with lots of potential.

At the moment the extension is also analysing my test projects and giving warnings about this. How can I disable inspection of specific (test) projects?

Update Its not about disabling specific Sonar rules or projects in SonarQube, but its about the Visual Studio extension SonarLint.

解决方案

In Visual Studio, open the project and then dig into the Reference section. There choose to edit the active rule set:

In the screen that opens select/deselect the rules you want for the specific project. Then hit save. This will most likely create a new .ruleset file in your project and instruct Roslyn to use that instead of the standard set.

The result is that the project file is updated with the <CodeAnalysisRuleSet> tag like this:

<CodeAnalysisRuleSet>UnitTests.Core.ruleset</CodeAnalysisRuleSet>

You can also use the add new file wizard and pick the "Code Analysis Rule set" option:

Then from the Analyze menu select "Configure Code Analysis for Solution", your newly added rule set can be selected from there and assigned to the project you want:

这篇关于如何为测试项目禁用SonarLint的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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