Welcome to MSDN Blogs Sign in | Join | Help

Code Metrics as Check-in Policy

This is the first in a series of posts around questions I am getting asked related to code metrics.

One question that is coming up is:

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 Thursday, November 15, 2007 11:39 PM by conorm

Comments

Thursday, November 15, 2007 8:23 PM by MSDN Blog Postings » Code Metrics as Check-in Policy

# MSDN Blog Postings » Code Metrics as Check-in Policy

Friday, November 16, 2007 12:06 AM by From the software development trenches

# Izindaba #18

Time for another weekly round-up of developer news that focuses on .NET, agile and general development

Monday, November 19, 2007 12:15 PM by Jeff Beehler's Blog

# Visual Studio Team System 2008 ships!

What else can I say? The big day has arrived (read the official word here on Soma's blog ) and we're

Tuesday, November 20, 2007 9:39 AM by Team System News

# VSTS Links - 11/20/2007

The Visual Studio Code Analysis Team Blog on Code Metrics as Check-In Policy and Code Metrics Customization....

Sunday, November 25, 2007 2:12 PM by From the software development trenches

# FxCop

In previous posts about Code Metrics and Code Reviews , I explored some metrics and techniques that I

Thursday, November 29, 2007 4:12 AM by naisioxerloro

# naisioxerloro

Hi.

Good design, who make it?

Tuesday, December 04, 2007 4:02 PM by Yo sólo pasaba por aquí pero ya que estoy....

# Visual Studio Team System 2008

Como muchos ya sabréis hace poco Microsoft lanzó al mercado Visual Studio 2008. Si estáis

Monday, January 14, 2008 4:22 PM by Ravings of a Developer TS

# 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

Sunday, March 09, 2008 5:44 PM by cross-posting de geeks.ms

# Novedades en Visual Studio Team System 2008

Como muchos ya sabréis hace poco Microsoft lanzó al mercado Visual Studio 2008. Si estáis interesados

New Comments to this post are disabled
 
Page view tracker