2010-07-27 2 views

답변

0

VS 2010 메트릭에 대한 확장 지점이 있는지 확실하지 않습니다.

다른 방법으로, 82 code metrics 함께 제공하고 정의 임계 값과 같은 짧은 Code Rule over LINQ Query (CQLinq)를 작성하는 것처럼 쉽게 그 NDepend 선택할 수 있습니다 :

warnif count > 0 from m in Application.Methods where 
m.NbLinesOfCode > 30 || m.CyclomaticComplexity > 10 
select new { m, m.NbLinesOfCode, m.CyclomaticComplexity } 
또한 기본 CQLinq 코드 규칙과 같은 추세를 찾아보실 수 있습니다

: Avoid making complex methods even more complex (Source CC)

// <Name>Avoid making complex methods even more complex (Source CC)</Name> 
// To visualize changes in code, right-click a matched method and select: 
// - Compare older and newer versions of source file 
// - Compare older and newer versions disassembled with Reflector 

warnif count > 0 
from m in JustMyCode.Methods where 
!m.IsAbstract && 
    m.IsPresentInBothBuilds() && 
    m.CodeWasChanged() 

let oldCC = m.OlderVersion().CyclomaticComplexity 
where oldCC > 6 && m.CyclomaticComplexity > oldCC 

select new { m, 
    oldCC , 
    newCC = m.CyclomaticComplexity , 
    oldLoc = m.OlderVersion().NbLinesOfCode, 
    newLoc = m.NbLinesOfCode, 
} 

또한, 제안 된 코드 메트릭을 구성 할 수 C.R.A.P method code metric에서처럼 자신의 코드 메트릭을 정의 :

// <Name>C.R.A.P method code metric</Name> 
// Change Risk Analyzer and Predictor (i.e. CRAP) code metric 
// This code metric helps in pinpointing overly complex and untested code. 
// Reference: http://www.artima.com/weblogs/viewpost.jsp?thread=215899 
// Formula: CRAP(m) = comp(m)^2 * (1 – cov(m)/100)^3 + comp(m) 
warnif count > 0 
from m in JustMyCode.Methods 

// Don't match too short methods 
where m.NbLinesOfCode > 10 

let CC = m.CyclomaticComplexity 
let uncov = (100 - m.PercentageCoverage)/100f 
let CRAP = (CC * CC * uncov * uncov * uncov) + CC 
where CRAP != null && CRAP > 30 
orderby CRAP descending, m.NbLinesOfCode descending 
select new { m, CRAP, CC, uncoveredPercentage = uncov*100, m.NbLinesOfCode } 
관련 문제