Visual Studio 2013 Ultimate中CA1502的自定义阈值 [英] custom threshold for CA1502 in visual studio 2013 ultimate

查看:147
本文介绍了Visual Studio 2013 Ultimate中CA1502的自定义阈值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题: CA1502的自定义阈值
讨论了如何设置自定义代码分析中代码度量标准规则的阈值。

This question: Custom threshold for CA1502 discusses how to set up custom thresholds for code metrics rules in code analysis.

我也有同样的问题,但认为旧问题已经过时了。

I have the same problem, but think that the old question is out of date.

要重复:


特别是,当方法具有
时,我们希望构建失败代码复杂度超过20。不幸的是,规则CA1502的
阈值为25:

In particular, we would like our Build to fail when a method has a code complexity of more than 20. Unfortunately, rule CA1502 has a threshold of 25:

当圈复杂度大于$ b $时,该规则将报告违规b大于25。

The rule reports a violation when the cyclomatic complexity is more than 25.

我们可以以某种方式更改它吗?

Can we somehow change this?

答案是编辑.fxcop文件以包括规则。
在Visual Studio 2013 Ultimate中,我们集成了代码分析和代码指标;但是我们似乎没有.fxcop规则-我认为以前是fxcop是一个单独的扩展名。

The accepted answer is to edit an .fxcop file to include the rules. In visual studio 2013 ultimate we have integrated Code Analysis and Code metrics; but we don't appear to have .fxcop rules - I think this used to be when fxcop was a separate extension.

有什么方法可以在Visual Studio生成的.ruleset文件?
还是我错过了如何以及在何处获取.fxcop文件?

Is there any way to edit the thresholds in the .ruleset files produced by visual studio? Or have I missed how and where to get .fxcop files in the more recent versions?

推荐答案

引用实际上是最近的。 .fxcop 文件的使用仍然是配置规则的唯一方法。 (如果您不喜欢此限制,则可以在 http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2406555-allow-code-analysis-rules-to-

The post you cited is actually pretty recent. The use of .fxcop files is still the only way to configure the rules. (If you're not fond of this limitation, you might want to vote at http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2406555-allow-code-analysis-rules-to-be-configured-via-ru.)

您可以使用FxCop 10.0 UI创建种子 .fxcop 文件,但您需要手动对其进行编辑以添加设置。要与Visual Studio集成,可以使用 CodeAnalysisProject MSBuild属性指定 .fxcop 文件的相对路径。

You can use the FxCop 10.0 UI to create a "seed" .fxcop file, but you will need to edit it by hand to add the settings. To integrate with Visual Studio, you can use the CodeAnalysisProject MSBuild property to specify the relative path to the .fxcop file.

这篇关于Visual Studio 2013 Ultimate中CA1502的自定义阈值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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