Disclaimer

The views expressed on this weblog are mine alone and do not necessarily reflect the views of my employer, Avanade.

Search
Recomends...
  • Code Complete, Second Edition
    Code Complete, Second Edition
    by Steve McConnell
Login
« Snip-It Pro 2.5 Preview | Main | Beware Databinding Dundas Silverlight Charts »
Saturday
Dec052009

A List of FxCop/Code Analysis Rules with MSDN Details

I am starting a fairly large project that will involve many developers. As part of the ramp up, I wanted to review all the code analysis/FxCop rules and choose which one we want to enforce as a check in policy for TFS. To help with the analysis, what I really wanted was a spreadsheet that listed all the rules and their descriptions that I can use to guide a meeting with a few other stakeholders.

Unfortunately, I couldn’t really find such a list. The closest I came was this list that had the rule type names and listed whether they were supported in a couple of versions of FxCop and Visual Studio Code Analysis 2005 and 2008. This list was good, but only had the pascal cased rule type names. These names weren’t always enough to really understand what the rule did.

What I really wanted was a list that had enough information to sit down and go through all the rules in a group so we could decide whether we wanted to enforce it as policy. The closest I was able to find was the msdn documentation located located here.

The msdn documentation was great. Each rule has its own page with a description, cause and how to fix instructions with other information. But visiting a page for over 200 rules is way too tedious. What I really wanted was a spreadsheet with all that information.

To get that list, I decided to write a program to scrape all the details from the MSDN documentation into a single list. To do so I navigate the main page to each category, then for each category, I navigate each of the rules and scrape all the relevant details by parsing the HTML. The code is written in C#, and leverages a codeplex project, the HTML Agility pack to allow me to use XPath to navigate the HTML returned via WebClient.

The code itself generates a pipe delimited file, which I then used Excel to import and save as an Excel 2007 Workbook.

Here is a link to a zipped version of the source code if you want to write something similar. And here is a link to the full spreadsheet (includes cause and how to fix columns) if you just want to have the output list of Rules with full detail.

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments (3)

I am now reading throught the code analysis rules these days, and because the rules are trivial, it is hard to decide if I should enforce it for a specific project. If I may ask, is there a filtered list of CA rules that is comparative important and might not cause noisy?
December 21, 2009 | Unregistered CommenterSusan
That's exactly why I created the spreadsheet. I wanted a single list with enough detail on each of the rules to go through as a group and decide whether to use it or not without neededing to visit each MSDN page for each rule.

Creating that filtered list is going to be different for each project. And I agree, there probably should be "themes" of code analysis rules that you can easily understand and pick, but I am not aware of any such selectors.

Good Luck
December 21, 2009 | Registered CommenterDavid San Filippo
I have to create a report for my project manager that what rules can be imposed for our project.
This is exactly what I need, List of Code Analysis rules in a spreadsheet.
Thanks
February 16, 2010 | Unregistered CommenterMansoor Mehmood

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
All HTML will be escaped. Hyperlinks will be created for URLs automatically.