26.04.2015 Views

Team Development with Visual Studio Team Foundation Server

Team Development with Visual Studio Team Foundation Server

Team Development with Visual Studio Team Foundation Server

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

2. Click the Check-in Policy tab and then click Add.<br />

3. In the Add Check-in Policy dialog box, select Code Analysis and then click OK.<br />

4. In the Code Analysis Policy Editor, select either Enforce C/C++ Code Analysis<br />

(/analyze) or Enforce Code Analysis For Managed Code. Select both if your<br />

project contains a combination of managed and unmanaged code.<br />

5. If you select Enforce Code Analysis For Managed Code, configure your required<br />

rule settings for managed code analysis based on your required coding standards. This<br />

determines precisely which rules are enforced.<br />

You can also create a custom check-in policy to perform checks that are not available by<br />

default. For example, you can disallow code patterns such as banned application<br />

programming interface (API) calls, or you can write a policy to enforce your team’s<br />

specific coding style guidelines, such as where braces should be positioned <strong>with</strong>in your<br />

source code.<br />

Additional Resources<br />

• For more information about creating and using a custom check-in policy, see “How<br />

To – Step Through Creating Custom Check-in Policies for TFS” in this guide.<br />

• To learn how to customize a check-in policy, see “Walkthrough: Customizing Checkin<br />

Policies and Notes” at http://msdn2.microsoft.com/enus/library/ms181281(VS.80).aspx<br />

• To view sample code that will disallow selected patterns on check-in, see “Checkin<br />

Policy to Disallow Certain Patterns” at<br />

http://blogs.msdn.com/jmanning/archive/2006/02/02/523125.aspx<br />

• To view sample code that will enforce comments on check-in, see “Sample Checkin<br />

Policy: Make Sure the Comment Isn’t Empty” at<br />

http://blogs.msdn.com/jmanning/archive/2006/01/21/515858.aspx<br />

• To learn how to register a new check-in policy, see “I’ve Made a New Check-In<br />

Policy! How Do I Add It?” at<br />

http://blogs.msdn.com/jmanning/archive/2006/02/07/526778.aspx<br />

Use Check-in Policies to Enforce a Code Quality Gate<br />

Use a combination of code analysis and testing policies to enforce a code quality gate.<br />

For example, use the supplied testing policy to ensure that specific tests are executed and<br />

passed prior to allowing source to be checked into TFS source control. You can also<br />

configure a code analysis policy to help ensure that your code meets certain quality<br />

standards by ensuring that security, performance, portability, maintainability, and<br />

reliability rules are passed.<br />

By enforcing this type of check-in policy in addition to policies that enforce coding<br />

standards and guidelines, you ensure your code meets a specific code quality gate.<br />

To enforce a code analysis check-in policy for a team project<br />

1. In <strong>Team</strong> Explorer, right-click your team project, point to <strong>Team</strong> Project Settings, and<br />

then click Source Control.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!