Page tree

Skip to end of metadata
Go to start of metadata

This topic explains how to configure the scope of analysis.

Modifying the Scope for a Test Configuration

By default, C/C++test analyzes the resources selected when the test configuration runs, but you can configure a narrower scope using the scope options available on the test configuration's Scope tab. See Scope Tab Settings: Defining What Code is Tested.

Modifying the Scope on the Project Level

You can configure the scope on the project level by excluding resources in the GUI (see Excluding Project Resources from Testing) or by using the -resource, -exclude, or -include options when running analysis in the command line (see Testing from the Command Line Interface).

Defining File Filters Based on Source Control Data

You can restrict the scope of analysis to locally modified files or to files modified on the current working branch by setting up file filters based on source control data. This allows you to focus on identifying and fixing bugs introduced by your recent code changes before checking the code into your source control system or merging with the main development stream.

You can define file filters:

Before you configure file filters, ensure that connection to a supported source control system is properly configured.

While modifying the default scope allows you to speed up analysis, it may impact violations reported by rules that require information about other resources included in the project. In particular, rules that analyze execution paths, calculate metrics, or check for duplicate code may be prone to reporting false positives or negatives if they have no access to files excluded from the scope.

For this reason, we recommend that you regularly perform full-scope analysis to ensure that all rule violations are detected. One example scenario is that a limited scope is analyzed when working with C/C++test on the desktop, while a full-scope analysis is performed during automated builds on a server.

Configuring File Filters with Advanced Settings

To configure file filters:

  1. Create an advanced settings file that includes C/C++test's advanced scope settings. See Advanced Scope Settings for a complete list of available settings. The contents of the advanced settings file may resemble the following:

    // This configuration narrows down the scope of analysis to locally modified files
    // (including header files).
    // This configuration narrows down the scope of analysis to files (including header files)
    // on the current working branch that differ from the main stream of development:
    // This configuration narrows down the scope of analysis to files (including header files)
    // on the current working branch that differ from branch "feature_372":
  2. Specify the path to the advanced settings. See Configuring an Advanced Settings File for details.

Advanced scope settings configured in the settings file apply to all test configurations and overwrite the scope options specified in a test configuration.

Advanced Scope Settings

scope.scontrol.files.filter.mode=localChecks only locally modified files.
scope.scontrol.files.filter.mode=branchChecks only files on the current working branch that differ from the reference branch. By default, the reference branch is the main integration stream, such as "master", "trunk", etc. You can specify a custom branch with scope.scontrol.ref.branch.
scope.scontrol.ref.branch=[branch or revision]Specifies the name or ID of the branch or revision with which the current working branch is compared to identify and analyze modified files. It applies when the scope.scontrol.files.filter.mode option is set to branch.

Enables checking all files that belong to the same compilation unit as the file that has been modified. This applies to both source files and header files.

C/C++test cannot analyze header files directly. This option allows you to ensure that modified header files are analyzed, even if the source files that include them remain unchanged.

  • No labels