I recently read an interesting post on Rob Caron's blog which referenced the importance of static code analysis. I agree with both Rob Caron and David Falkenstein that taking the extra time to run tools like this can help ensure the quality of the software product.
Recently, I have submitted my proposal for my Software Engineering Master's Project at California State University of Fullerton. The project in brief, will discuss how Team Foundation Server can be used/customized to promote quality control within a project such that it can remain within statistical control. One of the sub-points in my proposal summary was the fact that Team System could support static code analysis and that with each project (or each iteration if one were that ambitious), that rules could be modified based upon the possible issues which may been found responsible during root cause analysis on the Bugs which QA found. As a result there is a need to easily customize rules and deploy them to client machines. At last, I found a great resource on how to build custom rules with the Team System Static Code Analysis tool (FxCop). The FxCop Blog is a great resource.
While searching the weblog I found this great post in the FAQ section. It is a great reference for creating new rules and registering them with the Static Code Analysis tool in VSTS. Simply follow the steps listed and make sure to read some of the information which I have provided below.
The post contains an zip file containing the sample source required to build a custom rule which checks member prefixes. The entry is a little outdated, thus you should take the following into consideration.
- The directory where the rule dlls should be dropped has changed since the post was written and is now located at C:\Program Files\Microsoft Visual Studio 8\Team Tools\Static Analysis Tools\FxCop\Rules
- You only need to copy the .dll into the directory listed above. The other files are not required to register the rule. (The xml file is an embedded resource)
- More FxCop FAQ can be found on this Microsoft Forums post
- Screenshots
Screenshot: Drop the built dll into the following directory.
Screenshot: Code Analysis enabled with Samples rules enabled
Screenshot: Code Analysis warnings when Building the Solution
