This topic explains how to check custom requirements or tailor existing rules to your unique needs by either modifying existing rules or by creating custom rules.
Sections include:
A cornerstone of static analysis with C++test is the ability to customize both static analysis Test Configurations (the set of rules to check) and specific rules—including creating new custom rules.
The rules provided with C++test are a comprehensive set to select from, yet specific coding guidelines may differ slightly, or require well-defined exceptions to the rules, depending on the style of coding, or the nature of the application. Hence, it is very important to understand how C++test rules can be customized and deployed to a team of users.
C++test has the following types of rules:
A number of rules are parameterized, meaning that you can customize the nature of the rules by modifying the available rule parameters. Parameterized rules are marked with a special icon (a wizard hat with a radio button) in the Test Configurations dialog Static> Rules Tree tab:
Available rule parameters are described in the rule’s documentation. To view a rule’s description, right-click the node that represents that rule, then choose View Rule Documentation from the shortcut menu.
To modify rule parameters:
If you want to create multiple versions of a parameterized rule (such as a Flow Analysis rule that looks for user-specified definitions of leaks), create a "clone" of that rule (as described in Specifying Rule Mappings) then parameterize each of the rule instances. |
This section explains the general workflow for customizing existing rules and creating new rules with RuleWizard. See RuleWizard User Guide for details about RuleWizard capabilities and usage. |
Many of C++test’s pattern-based rules are edited with RuleWizard. C++test rules are physical files that can be loaded in RuleWizard and changed as needed. The built-in C++test rules are included in the installation directories.
Customizable rules are marked with the following wizard hat + wizard wand icon in the Test Configuration panel’s rules tree:
We strongly recommend that you leave the C++test built-in rules intact. To customize the rule, duplicate a built-in rule, and then modify the duplicate.
To customize a rule with RuleWizard:
All of the above steps can be controlled by menu options in C++test; you do not need to perform any actual file manipulations. C++test completely manages all rule components in these steps.
You can easily create your own rules using the RuleWizard module–a graphical rule creation and customization tool available in C++test.
With RuleWizard, rules can be created graphically (by creating a flow-chart-like representation of the rule) or automatically (by providing code that demonstrates a sample rule violation).
To open RuleWizard:
The RuleWizard GUI will then open. See the RuleWizard User Guide (accessible by choosing Help> Documentation in the RuleWizard GUI) for information on how to modify and save custom rules.
Before you can check custom rules, you must deploy them to C++test. The recommended deployment of customized or fully-custom rules leverages Team Server. As a rule, Parasoft infrastructure deployment relies on Team Server as a key component. C++test automatically connects to the Team Server using communication through a designated port. To set up your Team Server connection, go to Parasoft> Preferences> Team Server. See the Connecting to Team Server for additional details.
It is generally possible to deploy custom rules without Team Server, but it is notably more difficult to manage that deployment. If teams need to deploy custom rules, we strongly encourage the use of Team Server.
For details on how to use Team Server to deploy rules across the team, see Configuring Test Configurations and Rules for Policies.
Each rule that you import into the tool must have a unique rule ID. You should not import multiple rules that have the same rule ID. See Note on Duplicated Rule IDs for details. To specify rule categories using the rule ID, use the format |
See Configuring Test Configurations and Rules for Policies.
Before you can check custom coding rules that were designed in RuleWizard, you need to deploy them.
The following procedure describes how to enable custom rules if you are not using Parasoft Team Server to share rules across the team. If you are using Team Server, follow the instructions in Configuring Test Configurations and Rules for Policies. |
To deploy custom rules if you are not using Team Server:
See the Managing Custom Rules section in the DTP User Guide for information how to deploy custom rules on DTP.
Rules are recognized by rule ID within C++test If you have a rule with the same ID as a rule already in the built-in, user, or team categories, then the priority of usage is team/user/built-in. As a result, if you import a rule that matches the ID of a built-in rule, then the imported rule will be physically located in the default rule directory set in the Preferences panel, and the rule configuration will be use the imported rule instead of the built-in rule with the same name. If a rule is uploaded to Team Server, then the rule on Team Server will mask any user rules with the same ID, as well as the built-in rule with the same ID.