English 中文(简体)
CQL in ndepend and cppdepend to see changes in metrics across revisions
原标题:

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

问题回答

暂无回答




相关问题
Building CQL in NDepend for verifying MVVM patterns

I wanted to verify few design patterns in C# code by static analysis. I want to verify these using NDepend. The application is built with MVVM design style, so typical design patterns that I would ...

CQL request composition

Is it possible to compose requests in CQL ? I would like to write something like: SELECT TYPES FROM ASSEMBLIES "myassemblie" WHERE IsUsing SELECT METHODS FROM ASSEMBLIES "myotherassemblie" WHERE ...

Ndepend CQL to query types out of assembly wildcard

In order to determine what low-level framework types a web application is directly using, one has to define each and every assembly involved. SELECT TYPES FROM ASSEMBLIES "Company.System.Framework", "...

How to restrict NDepend methods query on type attribute

I m trying to get NDepend to identify long methods using a modified version of the standard "Methods too big" query. I don t want to report long methods that the developers have little control over, ...

热门标签