WillFuqua

Analyzing Code Quality with LINQ and NDepend

I’ve been building an open-source personal project (C# REPL) and spending a good chunk of time on code quality. I self-impose a zero-warning policy, use nullable reference types, track unit test coverage, etc.

After ensuring all the Visual Studio / Roslyn code analyzer warnings were fixed, I thought I’d try out NDepend to get a second opinion, and also understand its capabilities. After downloading a free trial of NDepend and spending some time with it, I was pretty impressed with its technical underpinnings as they’re exposed to the end user. Spoilers: It’s LINQ all the way down.

Static Analysis with LINQ

Out of the box, continue.

tagged as , , and

Finding Dead C# Code in an ASP.NET application

Large, long-lasting codebases tend to accumulate unused code, or dead code, over time. This happens as features are added, changed and removed.

Some types of dead code, like unreferenced methods, are easy to detect with Visual Studio's out-of-the-box static analysis. However, other types of dead code are trickier; maybe there's a method that's only referenced by unit tests, or it's referenced under a condition that's never valid:

if (DateTime.Now < new DateTime(1970, 1, 1))
{
    // some dead code
}

How can we detect this type of dead code? Rather than using static analysis to detect it, we can use dynamic analysis---the continue.

tagged as , and

Increasing Code Quality with SonarQube

I just posted an article about SonarQube, an open source static analysis tool, and how we set it up to scan every incoming GitHub pull request at work.

You can read it at the Jetabroad Tech Blog.

tagged as , and