tags:

views:

172

answers:

1

A client I work for has begun using NDepend as a replacement for FXCop, and the "architect" has compiled a list of practically unusable CQL queries, which I gather he has taken from advice from the NDepend website.

An example of what "I think" is an unhelpful query

WARN IF Count > 0 IN 
SELECT METHODS WHERE PercentageComment < 20 
AND NbLinesOfCode > 10

ie: must have at least 2 lines of comment for each 10 lines of code

So what I trying to gather is a useful set of queries that we can use as developers.

Please only provide a single query per response (with description) so that it can be voted accordingly. Please only provide a single query per response (with description) so that it can be voted accordingly.

+3  A: 

There are plenty of rules possible as I explained in this blog post. Some of my prefered are:

// New and refactored code should be covered by tests.
WARN IF Count > 0 IN SELECT METHODS WHERE PercentageCoverage < 100 AND (CodeWasChanged OR WasAdded)

// There shouldn't be namespaces dependency cycles.
WARN IF Count > 0 IN SELECT ASSEMBLIES WHERE ContainsNamespaceDependencyCycles

// Immutable classes should be tagged with an attribute to remain immutable in the future.
WARN IF Count > 0 IN SELECT TYPES WHERE !IsImmutable AND HasAttribute "YourNamespace.ImmutableAttribute"

// Code 100% covered by tests should be tagged with an attribute to remain 100% covered in the future.
WARN IF Count > 0 IN SELECT TYPES WHERE PercentageCoverage < 100 AND HasAttribute "YourNamespace.FullCoveredAttribute"

Patrick Smacchia - NDepend dev
Hi Patrick.. thanks for the response.. Would you possibly be able to break each of these rules into individual answers so they can be voted independently?
Xian