My New Favorite VS Code Extension

Tech Debt Tracker

Nobody likes technical debt and that’s why I love Tech Debt Tracker for VSCode. Not only does it do a great job of identifying technical debt in your existing code, it can keep you from introducing more debt. It has some collaboration tools I haven’t really explored yet but just the identification of technical debt is useful. The tool assigns a rating from A (good) to E (ugh) to your code. An A rating is saying This code is clean, easy to maintain, and likely to be bug-free. Who doesn’t want that?

I’ve been using the tool for several months of TypeScript development and I’ve come to believe the metrics used are valuable and accurate. Rarely will I disagree with the results. Speaking of results, they are broken out into multiple categories like, nesting depth, understandability, argument count and a few others. You can see the details inline in your editor and make a decision about what’s important to you to fix. There is also a Debt Ratings panel in the explorer so you can get an overview of the ratings of all the methods in a file.

Greenfield

If you’re lucky enough to be coding on a brand new project just use the tool to monitor your code development and strive to make every method an A. It’s fine to code up a B or C in the heat of battle. But before you release, refactor with a goal of A for everything. If for some reason you can’t, decide if that’s a //TODO or //FIX for the future or at least a notation about why you left it less than pristine shape. Sometimes the comment metric can get in the way.

The Boy Scout Rule

You should always leave your code cleaner than you found it. When you need to work on a method, and the Tech Debt Tracker grade goes down, you should fix it so that it’s no worse than when you started. If it wasn’t an A when you started you might consider doing future you a favor and making it an A before you consider yourself done.

Targeted Refactoring

Tech Debt Tracker can also be used to triage refactoring work. Look through the code base and find some code with the worst ratings. I would like to see a way for the tool to automatically find the worst code but at the moment that isn’t available.

Go Egoless

Try it out and leave your ego someplace safe. I had a lot of code that didn’t get an A. Sometimes I thought the tool was crazy, but I refactored anyway. In almost all cases, when I was done I had to admit my code had improved. In the (very) few cases where I didn’t think the code was more understandable, I just reverted to my original code. I figured after doing this for 40 years I had some instincts I could trust.