CQL in ndepend and cppdepend to see changes in metrics by version

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

I am evaluating ndepend and cppdepend for a mixed codebase. I am very impressed with both, especially how well cppdepend seems to handle our legacy and modern C ++.

If I can decide how to do this, I can do everything I need in CQL, but otherwise I will have to do something like compiling reports from the outside. Therefore, I will be grateful for the tips on automating and comparing report generation with CQL as a backup. Obviously, I would be happier to use CQL inside VisualCppDepend or VisualNDepend so that I can see the query results in a metric representation. Live research of results is a big deal with these tools compared to others.

Comments on CodeWasChanged and other suggestions such as IsInOlderBuild say make CQL run against the old assembly, which assumes that you cannot query through revisions.

The type of request I need is something like an imaginary syntax:

SELECT METHODS WHERE CodeWasChanged and MethodCe > 10

generalized to work through versions

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

or maybe

SELECT METHODS WHERE CodeWasChanged and MethodCe > 10 and Older(MethodCe < 10)
+3
source share
1 answer

Andy, CQLinq (Code Query and Rule over LINQ), you can see that a trend in code metrics is possible and, I hope, easy to achieve. For example, the default code rule Avoid the complexity of complex methods (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 recommend that you view the related code rules by default in the default group: Code Quality Regression

+3
source

Source: https://habr.com/ru/post/1780538/


All Articles