Here's the second part of he custom actions we are using in our project. You can read the first part here.
Mandatory add check-in comments
For each time a developer wants to check-in his code, we also want a short description of what is changed in the code for this check-in. We want this mandatory. After you have installed the power tools check-in policy pack, you have some extra policies, of which this is one of them.
How do add this policy?
- In Team Explorer, right-click your team project, select Team Project Settings, and then click Source Control.
- Click the Check-in Policy tab.
- Click Add and then select and configure the Changeset Comments Policy check-in policy.
What gives this for the developers?
When the developer wants to check-in his code, he must add comments on what is changed in the code for this check-in. One disadvantage with this policy is that you can add a space as comment. I’m still looking for a policy where this isn’t possible.
Check if all methods have comments
Code comment is very important. If a developer writes a method, and another developer use the method in another layer, intellisense will give some explication about the method and the parameters if the comment is added to the method.
For this you can add a check-in policy. We use the CCCP policy. Info can be found here : http://www.codeplex.com/TFSCCPolicy. This is a very powerful policy with a lot of options to setup.
How do add this policy?
- In Team Explorer, right-click your team project, select Team Project Settings, and then click Source Control.
- Click the Check-in Policy tab.
- Click Add and then select and configure the Check for Code Comments (///) Policy 3.0.0.0 check-in policy.
- You can edit the policy for selecting the language, which items must be checked (private, public, methods, properties and more). You can even exclude namespaces. Find all info on the codeplex website. Image 7
What gives this for the developers?
A developer creates a new method
and he forget to add comment about the method in his code using /// or any other tool like Ghostdoc<<< http://www.roland-weigelt.de/ghostdoc/>>>. Next he wants to check-in his code; he will get a check-in policy error.
He add the comment to the method.
Tries to check-in again and the policy is disappeared.
Code Analysis
Each project has its coding guidelines which the developers have to follow. Using the code analysis tool, you can setup up a validation on your code for certain guidelines. You can add code analysis for each project and when a developer builds, code analysis will be performed. If you have the power tools installed, you can replace or merge them with your check-in policy. But you can also add a check-in policy.
As we have already added the code policy as a work around for checking if the latest build was successful, we could use this policy and add our guidelines against which we want to check.
Later I will post the list of checks we use with the code analisys. I can only mention not to take all checks.
If you want to have a certain part of your code not checked by the Code Analysis,read this blog article http://blogs.msdn.com/fxcop/archive/2007/04/27/correct-usage-of-the-compilergeneratedattribute-and-the-generatedcodeattribute.aspx
How do add this policy?
See How to add the Last build must be successful policy.
What gives this for the developers?
When using code analysis, your code will be much more proper as it will check certain rules. You can add your own specific rules if you want.
Override policies in Check-in dialog
Developers can overwrite the policies when checking in their code. This is something we don’t want to have. For the moment it isn’t possible to change this. Maybe we should add a report which gives us an overview of all overrides. But you can also use a notifier tool. The source of a good one can be found here.
The only thing is that it don’t give back your subscription number and you can’t unsubscribe. So I’ve changed the program a bit. For the moment you get also your subscription number back and you can unsubscribe. Exception handling will be added later. Here’s the changed version. You need VS2008 to open it. Download my version here.