Tip: Integrating the Static Analysis tool with Rational Team Concert 3.0 Visual Studio Client
Summary
Beginning with Rational Team Concert (RTC) version 3.0, the RTC for Microsoft Visual Studio IDE provides the ability to run Static Analysis tool before you deliver changes to a RTC source control repository. You can set up your team’s process to not allow source code delivery if the static analysis fails. The project administrator normally configures this precondition. You can set up the precondition to use the Microsoft FxCop tool or any other custom tool that you can run from the command line. The tool needs to be able to accept DLL files as an input to analyze, and publish results via the Error List view in Visual Studio.
Setting up the Precondition
- In the RTC Eclipse client, in the project area editor, click the Process Configuration tab.
- In the Configuration area, expand Team Configuration and click Operation Behavior.
- In the Operations area, expand Source Control and click Deliver(client).
- Select the Preconditions and follow-up actions are configured for this operation check box.
- Click Add.
- In the Add Preconditions dialog box, select Require Static Analysis Run (Microsoft Visual Studio Client) and click OK.
- To use the Microsoft FxCop static analysis tool, complete the following steps:
- In the Select the Tool to run drop-down menu, select Microsoft FxCop.
- In the Tool Name field, accept the default or change the name. This name is displayed when error messages are listed in the Team Advisor window.
- In the Tool Home field, type the location of FxCopCmd.exe. The location can be an Environment variable, such as ${FXCOP_HOME}.
- In the Arguments field, type any additional arguments to pass to the FxCopCmd.exe command.
- In the Projects to exclude field, type a comma-separated list of project names to exclude from analysis.
- To use a custom tool, complete the following steps:
- In the Select the Tool to run drop-down menu, select Custom Tool.
- In the Tool Name field, accept the default or change the name. This name is displayed when error messages are listed in the Team Advisor window.
- In the Tool Command field, type the name of the command to execute.
- In the Tool Home field, type the tool location. The location can be an Environment variable.
- In the Arguments field, type any additional arguments to pass to the command. To invoke the custom tool, specify how to provide the input file to the command by using the ${0} argument. Also specify how to generate the output file by using the ${1} argument. For example, for the Scan.exe command, use the file argument to specify the input file and the -out argument to generate the output file. The Arguments field specifies the following: -input ${0} -out ${1}.xml.
- In the Projects to exclude field, type a comma-separated list of project names to exclude from analysis.
Delivering Changesets
If this precondition is set, before any Changesets are delivered the RTC Visual Studio Client will run the configured static analysis tool on the affected projects. The results of the source code analysis are displayed in the Team Advisor view. If the source code analysis runs clean, the delivery will proceed further and no errors will be displayed in the Team Advisor View. However, if the tool returns results because of errors in analysis, that information is displayed in the Team Advisor view and the delivery will not be allowed.
You should be able to open the results file by clicking on the link in the Team Advisor view.
Conclusion
Running source-code analysis tools has become standard practice in many organizations today. Although source-code analysis is not a cure-all for solving all software development ills, it is a strong method for reinforcing practices and identifying common coding problems early. By automating the use of Microsoft FxCop with RTC, the practice can quickly be adopted throughout the enterprise in a methodical way and the results can be integrated into everyday workflows.
Copyright © 2012 IBM Corporation