Reporting Code Analysis Defect Counts

    Code analysis defect counts are available in the cube that is part of the TFS Data Warehouse. This post shows you how to hook up Excel to show code analysis counts in a pivot table.

    First off you need to connect Excel up to the data warehouse that has the data. Under the Data tab in Excel select From Other Sources, From Analysis Services.


    Then you need to give the name of the server with the data warehouse. In the standalone TFS case this will be whatever machine is running TFS. Assuming you have read permissions with your Windows account you can click Next, otherwise enter a user name and password that has access to the server and click Next.


    Then, select the database (usually TfsWarehouse) and select the Build table.


    Click Next and then supply whatever additional information that will help you remember this data connection.


    Click Finish. Then define how you want to show the data in Excel - e.g. a pivot table.


    Click OK which gives you the following:


    In the PivotTable Field List, Expand Build Project where you will find two fields: Static Analysis Errors and Static Analysis Warnings:


    You can click the checkboxes to add these to the values for your table. In most cases Static Analysis Warnings would be the most useful since Static Analysis Errors would typically stop the build.

    To complete the picture you can play with the pivot table and pivot and filter as you see fit. As a simple example you can add the Build field:


    Which will give you one row per build in the pivot table.


    Of course this data can be combined with other build data and charted etc. according to your needs. We are considering what reporting to provide in future versions so would love to hear your feedback on this feature and what you would like to see.

Comments (10)
  1. In cases where warnings/errors are expected (e.g.: slow clean-up of a code analysis backlog), being able to group on rule category and/or rule would be useful.

    Statistics concerning message suppressions (groupable by scope) would also be quite helpful since they would allow one to identify potentially troublesome patterns in exclusion vs fix activities.

  2. conorm says:

    Nicole: thanks for your comments. I have read your blog posts on backlog cleanup and there are a lot of good ideas there.  I am using some of that information as we design new features in code analysis for a future release.

  3. The Visual Studio Code Analysis Team Blog on Reporting Code Analysis Defect Counts. Mike Azocar on New…

  4. abe says:

    Including code analysis summary results in the build summary report – similar to Cruisecontrol would be nice

  5. George says:

    I have added custom code rules (in VS2005). These fire as a Check-in policy. But when a code rule is broken and I try to check in. The check in window (under the Policy Warnings) says "Project XYZ rule settings are not in conformance with Code Analysis policy".

    I would like to double/right click on that and show the actual list of errors/warnings.


    It should populate the "Error List" window with the results from the Code Analysis.

    Can you please tell me if this is currently possible (ie am I missing a setting or something?) or if this feature will be added in a future release?



  6. conorm says:

    Thanks for your suggestions George.  We are looking in to improving the error reporting in the next release of Visual Studio and will bear this in mind.

    To answer your question: you are not missing anything in 2005.  We improved the reporting to tell you which projects were not in compliance in the 2008 version but still this is not to the individual error level.  In VSS 2008 We also enabled a feature to allow you to merge in the policy settings with your local project settings which makes it really easy to get in compliance.

    Hope this helps


  7. George says:

    Thanks for the reply Conor. We will just work with the current functionality and will look forward to the improved error reporting.



  8. andeezle says:


    Is the code metrics tool going to be made available in VS Pro Edition? (VS 2008 of course) If not, it damn well ought to be. Just becuase I’m not working on a team doesn’t make me any less important.


  9. David M. Kean says:


    > Is the code metrics tool going to be made available in VS Pro Edition? (VS 2008 of course)

    No, there is no plans to push Code Metrics into the Pro edition.

Comments are closed.

Skip to main content