Quantcast
Channel: Coding Paradox
Viewing all articles
Browse latest Browse all 16

Analyze .Net Code Quality with NDepend

$
0
0

NDepend is a static code analyser for .Net code. It can analyse your .Net application and can give you deep insights on the code base providing metrics like level of dependency, violated code rules, technical debt etc.

Getting Started

The installation process is quite simple. You can download the zip file from there website and just unzip it to a folder other than in “Program Files“. After unzipping, you can install the Visual Studio plugin which supports most of the version of Visual Studio including 2019 or you can also use the Standalone UI called Visual NDepend.

If you install it as a VS extension, you will get an option in Visual Studio as shown below

You can select the projects that you want to to analyse and you also have the option of filtering out the projects that you don’t want to include.

After selecting the projects, click on “Analyze a Single .Net assembly“. NDepend will then start analysing the project and you will be presented with a report after sometime. I ran it one of the legacy applications that i was working on and was quite impressed as it took only around 35 seconds to analyze the application which had a large code base. After the analysis is complete, a HTML report will get generated and you will be presented with the below dialog to guide you on what to do next.

The report will be generated as a webpage as shown below

It contains some huge amount of information related to your .Net solution. As you can see, it contains a sequence of diagram depicting various aspects of your solution.

  • The dependency matrix and graph gives you a good information about the dependencies in your solution
  • The TreeMap metric will give you a good idea about the cyclometric complexity in the the different and assemblies and methods.

Below that you will find the Application level metrics

It contains details about the Lines of code, number of methods, technical debt, Issues etc. One of the best feature i like about this is the information on Technical debt. If you dig further, it can show you the places where the debt has piled up and it also gives you the total effort it may take to reduce the debt. For most of the cases, the calculated effort seemed pretty accurate. You can also use it to do a Technical debt analysis before any check in to verify your changes are not accumulating any more debt.

Below that you will find information on the Quality Gates – showing you the number of checks that got passed and those that get failed. The Rules Summary is also displayed along with the number of rules that were violated along with there details.

You can also use the Visual NDepend dashboard as shown below to get all the info

The information displayed on the dashboard is similar to what you see in the Html report. All the data that you see in the dashboard in interactive. You can click on any of the sections and can drill down further to get more low level info.

The metrics that are displayed are based on the default rules. The rules are written in CQLinq or CodeQuality Linq which is similar to Linq and is easy to learn and modify. You can also create your own custom rules if you want.

If you click on the rules, it will also explain about the importance of the rule and why it should not be violated and it may also tell you how to resolve that issue. This is quite useful info for any developer.

It also gives information about Dead Code – i.e. code or method that is not being referenced from anywhere. This is especially useful if you have a legacy code base which was written a long time ago by other developers. Using this, i was able to identify a lot of useless code which was lying around in my legacy solution.

You can also get information whether your code follows the Object Oriented rules and it also shows the specific rules that were violated and the details.

Overall it is a great tool for .Net architects as well as developer to analyse potential issues within there code base. It presents you with a lot of information which may be a bit overwhelming at first but the Ndepend site provides some great info on how the same can be used as leveraged. The technical debt details along with the potential violations will help you ensure the quality of the code is maintained. The cost may be a bit high but you can try the trial for 14 days before deciding.


Viewing all articles
Browse latest Browse all 16

Latest Images

Trending Articles





Latest Images