This topic explains how to set up and run a post-commit code review scan that scans the source control system, identifies new/modified code that has been checked in, and matches the code with designated reviewers. 

Sections include:

Configuration Overview

Configuring a post-commit code review requires:

Configuring a Test Configuration for Post-Commit Code Reviews

For post-commit processes, a code review Test Configuration runs on the server each night to scan the source control system, identify new/modified code that has been checked in, and match the code with designated reviewers. 

The default Code Review Test Configuration settings must be reviewed and customized before you run Code Review.

To configure a Test Configuration that detects code changes and prepares them for review: 

  1. Open the Test Configurations dialog by choosing Parasoft> Test Configurations or by choosing Test Configurations in the drop-down menu on the Test Using toolbar button.
  2. Duplicate an existing Test Configuration (such as Built-in> Code Review> Post-Commit) or create a new one.
  3. In the Scope tab, choose Test files added or modified in the last ___ days. This determines what files are prepared for code review. For example, if the Code Review scanner will run daily, enter 1 in the days field. If it will run weekly, enter 7.
  4. Also in the Scope tab, review the File Filters> Path options settings and adjust them if desired. For details on these Test Configuration settings, see Configuring Preferences Overview).
  5. In the Common tab, check Update projects from source control.
  6. If your reporting preferences are not set to use a unique session tag for code review scans, go to the Common tab, enable Override Session Tag, then choose one of the preconfigured identifiers, or specify your own. This is the tag that will be assigned to all code reviews that stem from this Test Configuration.
  7. At the top of the Code Review tab:
    1. Check Enable Code Review Scanner.
    2. Check Generate comprehensive report (includes all scanners) if you want the report to include code review results from all available team scanners. If this is not enabled, the report will include only results for the session tag set for the current Test Configuration.
    3. Enable  Auto publish reviews if you want review tasks to be "published" (uploaded) automatically after this Test Configuration is run. If you use the -publish option with a nightly run, tasks will be "published" regardless of this setting.
    4. From the Generate tasks with priority box, indicate the priority that should be assigned to all code review tasks that are created using this Test Configuration.
  8. In the AuthorsReviewersMonitors, and Filters tabs, define how you want your code reviews assigned. Reviewers and monitors can be assigned to specific authors, or to specific project areas.
  9. (Optional) In the Code Review> Filters tab, modify the following options if desired:
  10. Click Apply to commit the new Test Configuration.
  11. Test the Test Configuration by selecting one of your projects in the project tree, then running the Test Configuration.

Preparing Code for Review - Automated Scanner Execution

For post-commit code reviews, SOAtest is typically scheduled to run in command-line mode at a regularly-scheduled interval (for example, daily). These tests execute the team’s Code Review Test Configuration. Each time a test runs, the Code Review scanner scans the designated source control repositories for new/modified code, then prepares any detected changes for review.

cli setup

  1. If you have not already done so, set up your projects in the UI.
  2. (Optional) if needed, use a localsettings file to override the Parasoft settings specified in the UI. See Configuring Localsettings for details.

cli execution

To run a Code Review scan from the command line interface, use a command such as:

parasofttestcli -publish -publishteamserver -config "team://xtest-codereview.properties" -resource 
"my_resource"

soatestcli -publish -publishteamserver -config "team://xtest-codereview.properties" -resource
"my_resource" -localsettings C:\tmp\localsettings.properties

The following options are used here:

If you are using a localsettings file to override the settings specified in the UI, you can add -localsettings; for example:

If you have multiple Parasoft products installed and want to run tests using parasofttestcli (rather than SOAtest-specific commands), be sure to add the name of the product after -config to specify which product’s Test Configuration you want to use. 

For example, to use parasofttestcli to run the SOAtest "Code Review" Team Test Configuration, you might use 

parasofttestcli -config "soatest.team://Code Review" -resource "my_resource"

Notifications

After each Code Review scanner execution, the designated reviewers will then be alerted that code is ready for review. The reviewers can perform the review as described in Reviewers - Reviewing Code Modifications.

After the review is completed, the authors can respond as described in Authors - Examining and Responding to Review Comments.

Running Post-Commit Scans with a Pre-Commit 

Process

Some teams who submit code for review via a pre-commit process also like to perform a regularly-scheduled post-commit scan in server mode (from the product’s command line interface) to:

If your team chooses to use post-commit scans with a pre-commit process, you can: 

Many teams want to enforce a policy that requires:

  • Every code change must be reviewed
  • Developers are not allowed to check-in code without it being reviewed.

One way to achieve this is to set up a hybrid code review process where developers are expected to  submit code to reviewers in pre-commit code reviews, then post-commit mode is used to verify that this process is being followed. 

The post-commit scan will report a code review task unless the corresponding pre-commit task has been marked as "done". You can customize the timeframe used to determine corresponding pre-commit tasks by changing the settings in the Filter tab’s Pre-commit search range in days option. By default, the search goes back 7 days from the post-commit scan. 

The manager can be set as a monitor. To ensure that all code has been reviewed before each release or build, he can then check that 1) no post-commit tasks are reported to him and 2) the monitor email does not show any pending review items from the pre-commit process. 

Be aware that in hybrid code review processes, the scanner will compare changes reported for pre-commit code review with changes committed to source control. 

However, sometimes minor changes that do not require review are introduced into source control—for instance, CVS headers like:

/*
* $RCSfile: MyFile.txt,v $
* $Revision: 1.13 $
*
* Comments:
*
* (C) Copyright Parasoft Corporation 1996.  All rights reserved.
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF Parasoft
* The copyright notice above does not evidence any
* actual or intended publication of such source code.
*
* Revision 1.2  2006/02/03 10:07:28  dan
* class repackaged
*
* Revision 1.1  2005/09/18 09:26:24  mark
* new file
*/

In such cases, the Test Configuration for the nightly post-commit scan should specify a regular expression that describes the automatically-generated code. This is entered in the Post to Pre-Commit matching option in the Test Configuration’s Code Review> Filters tab.

For example, to ignore changes in the above CVS header, you would enter (^ \* .*)|(^ \*$)

You can also set the Test Configuration to match (and then ignore) other changes that do not need to be reviewed. For example, the team might allow documentation changes to be committed directly to source control (without requiring review).