23 Sep

Announcing Code Health Metrics for CodeLens – A DevLabs Project

Category:General PostTag: :

One year ago I moved from Boise, Idaho, to Redmond, Washington, to work for Microsoft. At the time of our move, I owned a stretch-cab 1995 Ford F-250 four-wheel-drive pickup. That wasn’t going to work in the traffic of suburban Seattle, and I don’t foresee pulling a horse trailer here (or my buddy out of a mud hole), so I got a Scion IQ and sold the truck.

Becoming a Cleaner Driver

clip_image001I drove the Scion for a few weeks before noticing an occasionally lit green light on the dash board. At first, I merely noted the light. It didn’t bother me, but I had more things on my mind at the time, being new to the rush hour. I noted the light a few weeks later and looked closer to see it was an "eco" indicator. With some time on my hands sitting in the middle of the 520 freeway, I dug out the owner’s manual (I know, I know. I shouldn’t have done that while driving).

It turns out the eco indicator comes on when I am getting the most fuel efficient performance out of my car. Here is how Scott Mancuso described his relationship with his eco light in his Open Letter to My Car’s Eco Light.

"It only comes on when I?m driving like an environmental warrior. Sometimes people would ask, isn?t that really distracting? I would say, oh no, not at all. Actually, it?s really fulfilling, and it?s saving the environment, and it?s like a game and it?s not distracting at all because really all I want to do is satisfy the ECO light. I just want to keep it happy and on my dashboard where it can silently warm my field of vision with its comforting green glow. It?s like a game. I am at ease. I am helping."

This was exactly my experience. So, we built an eco-light for your code.

Becoming a Cleaner Developer

While our teams were creating the CodeLens feature this summer, we had some interns in from universities around the world working on projects. One intern spent her summer building a CodeLens indicator to show the measures used in calculating the Maintainability Index for software.

The very experimental Code Health Indicator for CodeLens looks like this.


It can tell you when you’ve made the method better.


Or, maybe you made it worse.


And details are provided at various levels of maintainability.


And even more detailed information is available in the tooltips.



Come and Get It

Today, we released that Indicator on DevLabs, an experimental delivery channel for Visual Studio add-ins, and you can install it on your Visual Studio 2013 Ultimate RC build. I think I am one of the few people interested in this indicator, so I just took control of the code and am releasing it via an experimental deployment channel so I can learn what you want the indicator to do before investing more time.

I really love this idea and hope this finds a nice home in your code quality toolkit. Some disclaimers before I point you to a link.

  1. This is an experimental add-in for VS. It will not have the same level of testing and rigorous inspection as in-product software.
  2. Only works on C# and VB.
  3. Only shows up on methods.
  4. UX needs work and we know that.
    Send your suggestions via the smiley face in Visual Studio, right here on this blog post, or via the Visual Studio User Voice page.

Download It Here

8 thoughts on “Announcing Code Health Metrics for CodeLens – A DevLabs Project

  1. Those metrics are useless to me. I don’t know how you would do it, but I would rather see stuff like number of memory allocations, number of properties changed on parameters, number of functions called that aren’t marked as [Pure].
    The ones you are using seem to only have the vaguest of correlations to code quality.

  2. I think these first few measures were taken first because they are known and relatively easy to capture. I agree they are only a start and a small one at that.

    It seems that you are also hoping to see runtime data in there. Yes?

  3. It stinks all the really cool add on’s Microsoft makes are for Ultimate. But you can’t even purchase Ultimate for a sane price. Not everyone needs every application Microsoft has ever made.

  4. While I get the frustration, it’s understandable. The new stuff rolls into Ultimate for awhile, then down into lower level SKUs over time. Our little group has to be profitable in it’s own right.

  5. Nice to see this sort of thing being built, although I’m not using VS2013 yet. I’ve actually been trying to make the same thing as a ReSharper plugin for my team, to look for “Clean Code” violations such as too many lines of code, too much cyclomatic complexity etc. I’d also like it to be able to suggest that you extract the inside of a foreach into a new method if there are lots of lines of code inside the loop.

Comments are closed.