The first post about NDepend
First of all, I’d like to thank you Patrick (owner of NDepend http://www.ndepend.com) to provide me the professional license of NDepend. This is definitely a cool and powerful tool even I just started using it.
In this post, I am going to introduce the simple steps I used to detect my project’s code quality.
Go to page http://www.ndepend.com/download and download the trial by simply providing your Email.
Follow the official instructions to install it (http://www.ndepend.com/docs/getting-started-with-ndepend).
Get familiar with the menu
Once installed, the NDEPEND menu will be added into the Visual Studio menu, where you can initiate code analysis. You can also do the same via NDepend Start Page links.
Starting to analyze
Click the link ‘Analyze VS solutions and VS projects’ to start analyzing.
In the dialog, select your solution and then click OK button to continue.
In the ‘Analyze a set of .NET assemblies’ dialog, you can resolve any issues highlighted in red before start the analyzing as sometimes some projects cannot be loaded or there are multiple versions can be found. Normally you can Cleanup and Rebuild your solution to fix most of the issues.
Click ‘Analyze XX .NET Assemblies’ button to continue.
In the result dashboard, you can find out the summary about your code quality, e.g. Code Rules violated cases, total line of code, comment lines and so forth. You can also create trend reports about these indicators.
I didn’t realize there are so many issues with my code. I will definitely use the information NDepend provided to fix all of them.
For example, by clicking one of the violated rule, I can get all the details and then fix them accordingly.
Some interesting and helpful diagrams
NDepend provides some helpful diagrams as well to help you understand your projects.
Abstractness vs. Instability
Treemap Metric View
With all these diagrams, I will immediately know where I am not not architecting or designing well (and there are a lot places to improve apparently ).
NDepend helps me to analyze my code and find out all the coding issues very quickly. I am surprised by the enormous set of rules NDepend provides to validate the code quality. This is absolutely an powerful and great tool to use if you want to improve your code quality and to adopt the preferred coding practices in .NET. I am just a beginner in NDepend’s world but I will definitely utilize it more in future.
I noticed there are some rules which are covered by Visual Studio but not appearing in NDepend’s result but it may be because I missed them, i.e. CA2241 Provide correct arguments to formatting methods. However this won’t really impact anything. I was actually thinking whether it is possible to bring all the Microsoft defined rules into NDepend?