简体   繁体   English

嵌套If的FxCop自定义规则

[英]FxCop custom rule for nested If

I am trying to get following metrics report for .Net assemblies 我正在尝试获取.Net程序集的以下指标报告
1. Boolean expression 1.布尔表达式
2. Nested If 2.如果嵌套
3. Method Parameters 3.方法参数
3. Nested try 3.嵌套尝试
4. Missing switch default 4.缺少默认开关
5. Class fan-out complexity 5.类扇出复杂度

Basically, I want to generate toxicity report for these complexities. 基本上,我想针对这些复杂性生成毒性报告。 I see that Sonar could generate same for java applications. 我看到Sonar可以为Java应用程序生成相同的内容。 But I don't see anything available with .Net using FxCop or nDepend. 但是我看不到使用FxCop或nDepend的.Net可用的任何东西。 I tried creating custom rules, but not able to get it done with any of tool. 我尝试创建自定义规则,但无法使用任何工具来完成它。
Is it possible to create custom rules with FxCop and get analysis report, and then create complexity measure from it? 是否可以使用FxCop创建自定义规则并获取分析报告,然后从中创建复杂性度量?
I have generated nested try rule with FxCop. 我已经用FxCop生成了嵌套的try规则。 But nested If seems difficult, because IL generate lot of goto statements which makes difficult to identify if "If" statements are nested or parallel placed. 但是嵌套的If似乎很困难,因为IL会生成很多goto语句,这使得很难确定“ If”语句是嵌套还是并行放置。 Same with Boolean complexity because of stack push-pop operations. 由于堆栈推入弹出操作,因此与布尔复杂度相同。

I think sonar make use of checkstyle for java to generate these reports. 我认为声纳利用java的checkstyle来生成这些报告。 Is it source code based analyser? 它是基于源代码的分析器吗? or also works with IL? 或也可以与IL合作? Do I need to work with styleCop to get it worked? 我需要使用styleCop使其工作吗?

Any help will be appreciated. 任何帮助将不胜感激。

Have you seen that NDepend supports the code metric IL Nesting Depth . 您是否看到NDepend支持代码度量IL Nesting Depth While it doesn't distinguishes between causes of the depth (if, goto, switch/case, loop...) it is computed from the IL and is pretty accurate in most situations. 尽管它不能区分深度的原因(例如,goto,switch / case,loop ...),但它是根据IL计算得出的,并且在大多数情况下非常准确。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM