我可以通过CQL找到许多没有吸气剂的方法吗? [英] Can I find number of methods without number of getters via CQL?
问题描述
我正在使用ndepend查找我的代码问题.现在,我发现有太多误报错误.
I am using ndepend to find my code problems. And right now I found that there are too much false positives mistakes.
例如,我有一个根本不复杂的类,但是它确实具有许多属性.因此,我将从NDepend得到警告,该类包含过多的方法.
For example, I have a class that is not complex at all, but it does has many properties. So, I will get a warning from the NDepend that the class has too many mehods.
这是现成的NDepend规则,要求类具有大量方法:
Here is the out-of-the-box NDepend rule to want classes with big number of methods:
WARN IF Count > 0 IN SELECT TYPES WHERE
NbMethods > 20
ORDER BY NbMethods DESC
我可以更改NDepend计算方法数量的方式,以便在需要的位置排除属性吗?
Can I change the way that NDepend calculate number of methods, so I could exclude properties where I want?
推荐答案
我可以更改NDepend计算方法数量的方式,以便在需要的位置排除属性吗?
Can I change the way that NDepend calculate number of methods, so I could exclude properties where I want?
Sergei,是的,这要归功于以下 CQLinq规则:>
Sergei, yes this is possible thanks to the following CQLinq rule:
warnif count > 0
from t in Application.Types
let methods = t.Methods
.Where(m => !m.IsPropertyGetter && !m.IsPropertySetter &&
!m.IsConstructor)
where methods.Count() > 20
orderby methods.Count() descending
select new { t, methods }
在这里,您不仅可以获得方法的数量,而且对于每种类型,您还将获得所有方法:
Here not only you'll get the number of methods, but for each type you'll get all methods:
这篇关于我可以通过CQL找到许多没有吸气剂的方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!