How to Set Up Check-in Policies to Enforce Coding Standards

- J.D. Meier, Jason Taylor, Alex Mackman, Prashant Bansode

The code analysis check-in policies that ship with Team Foundation Server enable you to automatically run static code analysis on code as it is checked in, to ensure that the relevant rules are satisfied. You can fine-tune the code analysis policy to check many different rules. For example, you can check rules governing design, interoperability, maintainability, mobility, naming conventions, reliability, and more.

To enforce a code analysis check-in policy for a team project
  1. In Team Explorer, right-click your team project, point to Team Project Settings, and then click Source Control.
  2. Click the Check-in Policy tab and then click Add.
  3. In the Add Check-in Policy dialog box, select Code Analysis and then click OK.
  4. In the Code Analysis Policy Editor, select either Enforce C/C++ Code Analysis (/analyze) or Enforce Code Analysis For Managed Code. Select both if your project contains a combination of managed and unmanaged code.
  5. If you select manage code analysis, configure your required rule settings for managed code analysis based on your required coding standards. This determines precisely which rules are enforced.

You can also create a custom check-in policy to perform checks that are not available by default. For example, you can disallow code patterns such as banned API calls, or you can write a policy to enforce your team’s specific coding style guidelines, such as where braces should be positioned within your source code.

Additional Resources

Last edited Jul 25, 2007 at 12:04 PM by prashantbansode, version 1

Comments

No comments yet.