NDepend Linq 将一个查询的输出与另一个查询混合
NDepend Linq mixing the output of one query with another
我想将来自 NDepend 的查询限制为一组特定的类型。但是如果我尝试使用正常分配,我会收到以下错误:
Only single statement queries are supported. If you
wish to define a function or a variable global to the query, use a
range variable defined in a 'let' clause declared before the query.
For example:
let myVar = ThirdParty.Types.WithName("IDisposable").Single() let
myFunc = new Func<IType, bool>(t => t.NbLinesOfCode > 10) let ... from
t in Types where t.Implement(myVar) && myFunc(t) select new { t,
t.NbLinesOfCode }
但是我的第二次尝试也失败了
let temp = from t in Types
let depth0 = t.DepthOfIsUsedBy("PrintOddsDrawing")
where depth0 >= 0 orderby depth0
select new { t, depth0, t.NbTypesUsed }
// <Name>Methods too complex - critical</Name>
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 }
只需将 warnif count > 0
header 放在查询的开头
warnif count > 0
let temp = from t in Types
...
第二个问题:是否还有一种方法可以将所有代码气味调查仅应用于与我正在处理的类型相关的缩减子集
您可以执行如下查询(将 TypesAndMembers.WithNameLike("m")
替换为您自己的子集定义)
let subset = TypesAndMembers.WithNameLike("m").ToHashSet()
from i in Issues
where i.CodeElement.IsTypeOrMember &&
subset.Contains(i.CodeElement)
select new { i, i.Debt, i.Severity }
我想将来自 NDepend 的查询限制为一组特定的类型。但是如果我尝试使用正常分配,我会收到以下错误:
Only single statement queries are supported. If you wish to define a function or a variable global to the query, use a range variable defined in a 'let' clause declared before the query. For example: let myVar = ThirdParty.Types.WithName("IDisposable").Single() let myFunc = new Func<IType, bool>(t => t.NbLinesOfCode > 10) let ... from t in Types where t.Implement(myVar) && myFunc(t) select new { t, t.NbLinesOfCode }
但是我的第二次尝试也失败了
let temp = from t in Types
let depth0 = t.DepthOfIsUsedBy("PrintOddsDrawing")
where depth0 >= 0 orderby depth0
select new { t, depth0, t.NbTypesUsed }
// <Name>Methods too complex - critical</Name>
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 }
只需将 warnif count > 0
header 放在查询的开头
warnif count > 0
let temp = from t in Types
...
第二个问题:是否还有一种方法可以将所有代码气味调查仅应用于与我正在处理的类型相关的缩减子集
您可以执行如下查询(将 TypesAndMembers.WithNameLike("m")
替换为您自己的子集定义)
let subset = TypesAndMembers.WithNameLike("m").ToHashSet()
from i in Issues
where i.CodeElement.IsTypeOrMember &&
subset.Contains(i.CodeElement)
select new { i, i.Debt, i.Severity }