Accelerating Code Analysis and Improving Code Quality with NDepend

I’ve been working on a project for a customer where a fairly large pile of code has been written by an offshore vendor and I was brought in to do a code review and some clean up and verification of the logic. As I dove into the code, the smells started to become overwhelming.

Trying to work through the entire code base and figure out where to focus my clean up efforts first was a daunting task. However, a wonderful tool called NDepend came to the rescue. If you haven’t ever heard of this awesome tool and you have oversight responsibility for a team of developers, you should really check it out.

I can’t show screenshots here because the code has namespaces that reveal the client name, but you can find a number of screenshots on the NDepend site itself.

Basically NDepend will do a static analysis of your code base and help you identify everything from tightly coupled code containing too many dependencies (thus the name), but tons of other code metrics including line of code count, cyclomatic complexity, and others. It has a rich interactive UI for drilling into the code from the graphical charts that present you color coded views of where you need to focus as well as a web report generated view that you can view through a browser. You can analyze the code through a number of metrics, and it comes with a powerful query language called CQL (Code Query Language) that lets you look for particular patterns that you want to focus on.

I’d say this is a tool any technical lead, senior developer, or architect in charge of code quality should have in their toolbox.