CK metrics from C# project with Ndepend

断了今生、忘了曾经 提交于 2019-12-23 04:55:17

问题


I have project for school. Now I need to make from it report of all metrics CK (Chidamber Kemerer metrics). The report has to be like table of all those metrics. Question is how to make it from Ndepend this report which it generates it is not what I am looking for.

Please help and say how to do it... maybe some tips, documents or something this is very important...


回答1:


Ok, so if we are talking of these Chidamber Kemerer metrics, the NDepend ability to write Code Queries and Rules over LINQ queries (CQLinq) will answer all your needs. For example:

WMC Weighted Methods Per Class

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 }

DIT Depth of Inheritance Tree

warnif count > 0 
from t in JustMyCode.Types 
where t.IsClass
let baseClasses = t.BaseClasses.ExceptThirdParty()
where baseClasses.Count() >= 5
select new { t, baseClasses, 
                // The metric value DepthOfInheritance takes account
                // of third-party base classes
                t.DepthOfInheritance 
}

NOC Number of Children

from t in Types 
where t.IsClass
let childClasses = t.DerivedTypes
where childClasses.Count() > 0
orderby childClasses.Count() descending 
select new { t, childClasses }

CBO Coupling between Object Classes

from t in Application.Types 
let typesUsed = t.TypesUsed.ExceptThirdParty()
orderby typesUsed.Count() descending 
select new { t, typesUsed }

and so on...




回答2:


Does NDepend have a direct way in CQL to measure RFC (RFT)? Or do we have to write a CQL query for recursive counting invoked methods in used classes (types) our-self? If so, how does it look like?



来源:https://stackoverflow.com/questions/4493316/ck-metrics-from-c-sharp-project-with-ndepend

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!