You can write C# LINQ code queries to obtain pretty much any code metric you need.
length of identifiers
from t in Application.Types
select new { t, t.SimpleName.Length }
fan in / fan out
from t in Application.Types
select new { t, t.TypesUsed, t.TypesUsingMe }
weighted method of class
from t in Application.Types
select new { t, t.CyclomaticComplexity }
coupling of class objects (according to this definition)
from n in Application.Namespaces
let NumberOfClasses = n.ChildTypes.Count()
let NumberOfLinks = n.ChildTypes.SelectMany(t => t.TypesUsed).Distinct().Count()
select new { n, CBO = NumberOfLinks / (float)NumberOfClasses }
You can then transform a code query into a code rule with the prefix warnif count > 0
and save the rule to get it executed in Visual Studio and/or in your BuildProcess.
// <Name>Type name shouldn't exceed 25 char</Name>
warnif count > 0
from t in Application.Types
where t.SimpleName.Length > 25
orderby t.SimpleName.Length descending
select new { t, t.SimpleName.Length }
