NDpend 变量计算
NDpend Variable Calculations
尝试使用自定义 NDepend 变量代替常量,但无法解决围绕 let
关键字的 NDepend 语法的一些复杂问题。
其中一个内置查询是:
warnif count > 0 from m in JustMyCode.Methods where
m.CyclomaticComplexity > 30 ||
m.ILCyclomaticComplexity > 60 ||
m.ILNestingDepth > 6
orderby m.CyclomaticComplexity descending,
m.ILCyclomaticComplexity descending,
m.ILNestingDepth descending
select new { m, m.CyclomaticComplexity,
m.ILCyclomaticComplexity,
m.ILNestingDepth }
而我真正想做的不是使用 0 常量值,而是将其基于代码库。大致如下:
let tenPercent = (JustMyCode.Methods.Count() / 100 * 10)
warnif count > tenPercent from m in JustMyCode.Methods where
m.CyclomaticComplexity > 30 ||
...
这可能吗?
你可以这样写...
warnif percentage > 10
from m in Application.Methods where
m.CyclomaticComplexity > 2
select new { m, m.CyclomaticComplexity }
...但此功能有点隐藏(percentage
关键字未出现在智能感知中),因为它尚未完善。百分比基数是方法总数(包括抽象方法、第三方方法、生成方法……),这个基数实际上是不可配置的。此外,常量值(此处为 10)不能是表达式。
尝试使用自定义 NDepend 变量代替常量,但无法解决围绕 let
关键字的 NDepend 语法的一些复杂问题。
其中一个内置查询是:
warnif count > 0 from m in JustMyCode.Methods where
m.CyclomaticComplexity > 30 ||
m.ILCyclomaticComplexity > 60 ||
m.ILNestingDepth > 6
orderby m.CyclomaticComplexity descending,
m.ILCyclomaticComplexity descending,
m.ILNestingDepth descending
select new { m, m.CyclomaticComplexity,
m.ILCyclomaticComplexity,
m.ILNestingDepth }
而我真正想做的不是使用 0 常量值,而是将其基于代码库。大致如下:
let tenPercent = (JustMyCode.Methods.Count() / 100 * 10)
warnif count > tenPercent from m in JustMyCode.Methods where
m.CyclomaticComplexity > 30 ||
...
这可能吗?
你可以这样写...
warnif percentage > 10
from m in Application.Methods where
m.CyclomaticComplexity > 2
select new { m, m.CyclomaticComplexity }
...但此功能有点隐藏(percentage
关键字未出现在智能感知中),因为它尚未完善。百分比基数是方法总数(包括抽象方法、第三方方法、生成方法……),这个基数实际上是不可配置的。此外,常量值(此处为 10)不能是表达式。