문제

CQL makes it easy to find methods where CodeWasChanged but I also need to compare the metrics - I want to find modified code and see if it has improved or not.

I'm evaluating ndepend and cppdepend for a mixed code base. I'm very impressed with both, especially how well cppdepend seems to cope with our legacy and modern c++.

If I can work out how to do this then I can do everything I need within CQL but otherwise have to do something like combine reports externally. So I'd appreciate tips on automating and comparing report generation from CQL as a fallback. Obviously I would be happier using CQL inside VisualCppDepend or VisualNDepend so I can see the results of queries in the metric view. The live exploration of results is the big deal with these tools, compared to others.

The comments on CodeWasChanged and other clauses like IsInOlderBuild say forces CQL to be run against the older build which suggests you can't have a query work across revisions.

The kind of query I'd like is something like, imagining syntax:

SELECT METHODS WHERE CodeWasChanged and MethodCe > 10

generalised to work across versions

SELECT METHODS WHERE CodeWasChanged and MethodCe > 10 and BaseMethodCe < 10

or maybe

SELECT METHODS WHERE CodeWasChanged and MethodCe > 10 and Older(MethodCe < 10)
도움이 되었습니까?

해결책

Andy, with CQLinq (Code Query and Rule over LINQ) see trending in code metrics is possible and hopefully easy to achieve. See for example the default code rule 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,
}

We'd advise to browse related default code rules in the default group: Code Quality Regression

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top