A few customers asked us to indicate what tools they can use to analyze and improve the VB.NET code that VB Migration Partner generates. Our answer has always been: get a copy of NDepend. In a nutshell, NDpend allows you to

  • compute as many as 82 different code metrics, virtually all the code metrics you can think of
  • generate dependency graphs between methods, classes, and assemblies
  • compare two different versions of your codebase
  • gather code coverage results from NCover and Visual Studio Team System
  • perform very sophisticated queries on the analysis results, using a CQL, a query language that resembles SQL
NDepend is perfectly integrated with Visual Studio. For example, you can browse the result of a CQL query, double-click on a class or method name, and - presto! - you jump to the code inside that class or method.

Unlike all other code analysis tool I know about, which offer a limited set of reports, NDepend allows you to create your custom report thanks to the CQL query language. For example, consider these CQL example, taken from NDepend Feature page:

Which methods have been refactored since the last release and is not thoroughly covered by tests?
SELECT METHODS WHERE CodeWasChanged  AND  PercentageCoverage <  100

Which classes implement a particular interface?
SELECT TYPES WHERE IsClass AND Implements "System.IDisposable"

Which methods create objects of a particular class or assign a particular field?
SELECT METHODS WHERE CreateA "MyNamespace.MyClass"
SELECT METHODS WHERE IsDirectlyWriting "MyNamespace.MyClass.m_Field"

What are the 10 most complex methods?
SELECT TOP 10 METHODS ORDER BY CyclomaticComplexity

Which public methods could be declared as private?
SELECT METHODS WHERE IsPublic AND CouldBePrivate

Which complex method is not enough commented?
SELECT METHODS WHERE  CyclomaticComplexity >  15 AND  PercentageComment <  10

CQL does have a learning curve, but if you are familiar with SQL you will find yourself comfortable with it very soon. NDepend even comes with an integrated CQL editor that supports intellisense.

You can learn more about NDepend by watching this short but very informative video.