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:
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.
Comments
Anonymous
November 15, 2007
PingBack from http://msdnrss.thecoderblogs.com/2007/11/15/code-metrics-as-check-in-policy-2/Anonymous
November 15, 2007
Time for another weekly round-up of developer news that focuses on .NET, agile and general developmentAnonymous
November 19, 2007
What else can I say? The big day has arrived (read the official word here on Soma's blog ) and we'reAnonymous
November 20, 2007
The Visual Studio Code Analysis Team Blog on Code Metrics as Check-In Policy and Code Metrics Customization....Anonymous
November 25, 2007
In previous posts about Code Metrics and Code Reviews , I explored some metrics and techniques that IAnonymous
November 28, 2007
Hi. Good design, who make it?Anonymous
December 04, 2007
Como muchos ya sabréis hace poco Microsoft lanzó al mercado Visual Studio 2008. Si estáisAnonymous
January 14, 2008
So I have had at least a half dozen customers ask about this recently, and found a great article on theAnonymous
March 09, 2008
Como muchos ya sabréis hace poco Microsoft lanzó al mercado Visual Studio 2008. Si estáis interesadosAnonymous
February 05, 2009
[ Nacsa Sándor , 2009. január 19. – február 5.] Ez a Team System változat fejlett eszközrendszert kínál