Welcome to MSDN Blogs Sign in | Join | Help

Ravings of a Developer TS

I have been with Microsoft as part of their Develop Platform and Evangelism team since July of 2006. As I go about my day to day, I often stumble across things I want to share out with the community. This is my soap box. I am based out of the Midwest District, so please don't be offended if you see most of the events I post being in Illinois, Indiana and Wisconsin. If you are ever curious if the event will be in a city near you, just ask :)

Syndication

Enforcing Code Metric Policies on Check-in

So I have had at least a half dozen customers ask about this recently, and found a great article on the Code Analysis Team blog.  Yoinked from their post...

Can a check-in policy be defined based on code metrics in TFS?

Well, code metrics itself does not have a check-in policy but fortunately the Maintainability Index, Class Coupling, Depth of Inheritance and Complexity metrics are all available as rules in Code Analysis in Visual Studio.  This means you can use code analysis check-in policy enabled with those rules.  The rules are grouped under the "Maintainability Rules" Category and are configured as follows:

Metric
Corresponding Rule
Threshold

Depth of Inheritance
CA1501 AvoidExcessiveInheritance
Warning at above 5 levels deep

Complexity
CA1502 AvoidExcessiveComplexity
Warning at above 25

Maintainability Index

CA1505 AvoidUnmaintainableCode
Warning at below 20

Class Coupling
CA1506 AvoidExcessiveClassCoupling

Warning at above 80 for class and above 30 for a method

In the policy editor this would look like the following:

Code Metrics as a check-in policy

This allows you to enforce that code meets these thresholds before check-in.  In future we are looking in to allowing the threshold values to be changed.

Published Monday, January 14, 2008 3:22 PM by AngelaB

Comments

# Enforcing Code Metric Policies on Check-in @ Monday, January 14, 2008 4:32 PM

So I have had at least a half dozen customers ask about this recently, and found a great article on the

Noticias externas

# VSTS Links - 01/17/2008 @ Thursday, January 17, 2008 10:36 AM

Willy-Peter Schaub on TFS - The fascination world of Process Templates. The Microsoft UK Developer Tools...

Team System News

Anonymous comments are disabled
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement  
Page view tracker