blog
Ottorino Bruni  

Review of NDepend: A Swiss army knife for .NET developers

Some time ago, I had the privilege of being contacted by Patrick Smacchia, CEO and lead developer at NDepend to try out NDepend v2023.

Having never used NDepend before, my curiosity was naturally piqued. In my daily role as Senior Software Engineer, we extensively employ static code analysis tools as part of our Azure DevOps build pipelines. While running them on our machines isn’t mandatory, so why not first perform this kind of static analysis directly on your PC without having to wait?

Okay, I’ve given a good introduction, but what is NDepend, and what does it do?

What is NDepend?

NDepend is a powerful .NET Code Quality Tool that seamlessly integrates with Visual Studio and other DevOps platforms, supporting the latest technologies. It prioritizes quality in recent changes, offering a seamless PASS/FAIL Quality Gate and smart technical debt estimation.

What are the Key Features of NDepend?

  1. Easily Manage Large Projects: NDepend’s in-depth reporting and toolset empower companies to enforce coding standards and maintain complex projects.
  2. Code Rule and Code Query: Utilize hundreds of default code rules and C# LINQ (CQLinq) for customizable rule creation and code querying.
  3. Powerful Dependency Graph and Matrix: Explore code structure and identify architectural flaws with the industry’s most powerful dependency graph and matrix.
  4. Smart Technical Debt Estimation: Estimate the cost and severity of issues through intelligent and customizable C# formulas for realistic proposals.
  5. Continuous Code Quality: Maintain technical debt continuously and redeem it over time with NDepend’s unique approach.
  6. And more…

How to get started with NDepend?

Unfortunately, NDepend doesn’t integrate with Visual Studio for Mac and Rider, as stated here, so I had to install it on a Windows machine.

As it says on the website “The primary goal of using NDepend.Console.MultiOS.dll on macOS or Linux is to generate code quality reports from a CI/CD pipeline” and you can get more information on how to install it here.

Installation on Windows is straightforward; just select the version of Visual Studio. In the Extensions menu there will be NDepend, you select the solution and the tool will start analyzing the assemblies.

I wanted to try it on my SolidPrinciples project, and within seconds I got this very detailed report. There are a few exclamation points and room for improvement, but overall, it passed testing. ✅

What does the report show?

  • Overview: The NDepend report’s overview provides a detailed snapshot of the analysis and the Application Metrics section provides comprehensive insights into the project’s codebase.
  • Issues: Lists C# code files sorted by the total number of issues, clicking on a file name drills down into the source code.
  • Rules: details violations across the code, offering insights on issues, debt estimations, and visual cues for resolution progress.
  • Quality Gates: presents a condensed checklist, assessing if code passes all gate checks and now featuring improved color coding/visual cues.
  • Trend: Showcases a centralized collection of line charts derived from code analysis reports.
  • Logs: Captures logs from code analysis output during runtime.

Additionally, there are diagrams providing more information about the quality of the solution:

  1. Dependency Graph: Visualizes dependencies among .NET assemblies in a static diagram, offering a high-level overview of the application architecture.
  2. Dependency Matrix: Represents the Dependency Structure Matrix (DSM) between .NET assemblies, providing a condensed display of component dependencies. Matrix cells indicate the number of types involved in coupling. Explore further with NDepend’s interactive Dependency Matrix in the UI.
  3. Treemapping Code Metrics: Utilizes a Treemap to represent the code base in the Metric View, with rectangles proportional to method lines of code.
  4. Abstractness versus Instability Diagram: Helps identify potentially challenging assemblies for maintenance. Abstractness is determined by the presence of abstract types, while instability gauges how types are used by other assemblies.

Why should I use NDepend?

NDepend is a handy tool for both solo developers and teams. It helps individuals improve code and supports teams in automated code reviews, refactoring, and project health visualization. Whether you’re working alone or in a team, NDepend is a useful tool for maintaining good code and building solid projects. It offers a high-level view of your codebase, facilitates comparison of code quality over time, and serves as a powerful aid for refactoring legacy code.

Conclusion

NDepend has consistently lived up to expectations, maintaining its strong reputation for building upon existing features and enhancing them without disrupting the core functionality. This aligns with the typical trajectory of successful software products.

If you appreciate Clean Code and believe, like me, that this tool can enhance your project’s quality and robustness, I strongly recommend giving it a try. NDepend offers a 14-day free trial for fellow .NET developers to explore its feature-rich, developer-friendly capabilities. Access the trial here.

 

If you think your friends/network would find this useful, please share it with them. I’d really appreciate it.

Thanks for reading! ????

🚀 Discover CodeSwissKnife, your all-in-one, offline toolkit for developers!

Click to explore CodeSwissKnife 👉

Leave A Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.