• Post Calendar

    December 2015
    S M T W T F S
    « Nov   Oct »
     12345
    6789101112
    13141516171819
    20212223242526
    2728293031  

What’s Your Quality Bar?

I put “New Horizontal Tab Group”, “Run Code Analysis on Solution” , and “Analyze Code Coverage for All Tests” on a Visual Studio Toolbar called “Quality”.

Before you check-in

The steps before checking in code should be:

  • Get Latest Version
  • Build
  • Run Code Analysis on Solution
  • Analyzed Code Coverage for All Tests

Most advice as the first two and probably the last listed, but I think all 4 are important.

To make this easier and almost automatic, I put together a tool bar so I can just press a button for two of these actions.

image

Now I renamed these so that they don’t take up as much room, but they are there.

Get Latest Version

You want to make sure that you have all the latest code merged in with yours before you do your check-in, so this is the first step. If you don’t do this first then you’ll need to repeat some steps again before checking in.

Build (Skip)

Ok… I actually skip this, because it happens automatically in the next two steps.

Code Analysis

I have Microsoft All Rules turned on for Code Analysis.

image

But even though you check the box that says “Enable Code Analysis on Build” it doesn’t seem to report these warnings. So instead, I need to run “Run Code Analysis on Solution”. Our projects have no code analysis warnings (with very few suppressions). You want to get to zero and stay there. It’s always an expensive effort to go back and get them down to zero when they start to pile up.

Code Coverage

And obviously you want to make sure all your unit tests pass. As a matter of practice I run the code coverage to see if there are big changes in that number. The current project I’m working on has about 94% code coverage. We use a `.runsettings` file to control which libraries we analyze.

image

Following these steps can really improve the quality of your code and reduce bugs that escape. Just using this will typically catch misspellings in your Resources.resx file. If you get too many warnings these will slip by you and make it to your customer.

I’m sure there are some good posts on how to create and edit options in a Toolbar in Visual Studio 2015.

New Horizontal Tab Group?

Why is that in the quality bar? I routinely will use that to split my view so that my unit test is in the top group while the code I’m working on is in the bottom group. I think quickly arranging things so you can see your tests and code at the same time really helps your quality.

Leave a Comment