This topic explains how to check custom requirements or tailor existing rules to your unique needs by either modifying built-in static analysis rules or by creating your own static analysis rules.
Sections include:
Customizing Parameterized Rules
Many rules are parameterized, meaning that you can customize the nature of the rules by modifying the available rule parameters. Many naming convention rules are parameterized so that you can specify the naming convention that you want to check. Other rules are parameterized so that you can control rule options such as the scope of checking or choose among different interpretations of the rule. Parameterized rules are marked with a special icon (a wizard hat with a radio button) in the Test Configurations dialog Static > Rules Tree tab:
If a rule is parameterized, its parameters are described in the rule’s description. To view a rule’s description, right-click the node that represents that rule and choose View Rule Documentation.
To edit a parameterized rule:
- Open the Test Configurations dialog by going to Parasoft > Test Configurations or by choosing Test Configurations in the dropdown menu on the Test Using button on the tool bar.
- Open the Static > Rules Tree tab for any Test Configuration. The modified rule parameters will be applied to all Test Configurations, so it does not matter which Test Configuration you select in this step.
- Expand the rule’s category branch.
- Right-click the parameterized rule that you want to modify and choose View/Change Rule Parameters.
- Modify the rule parameters in the dialog that opens.
- Click OK to save your changes.
About RuleWizard
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.
RuleWizard (available in the Architect and Automation edition only) allows you to create custom static analysis rules. SOAtest can automatically enforce any valid rule created in RuleWizard. By creating and checking custom rules, teams can verify unique project and organizational requirements, as well as prevent their most common errors from recurring.
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). No coding or knowledge of the parser is required to write or modify a rule.
There are two ways to open RuleWizard:
- Go to Parasoft > Launch RuleWizard.
- Click New on the Test Configurations panel’s Static tab.
The RuleWizard GUI will then open. The RuleWizard User's Guide contains information on how to modify, create, and enable custom rules. You can access it by going to Help > Help Contents or Parasoft > Help (depending on your installation) and opening the "SOAtest RuleWizard User’s Guide" book.
If you are using a Linux distribution that uses a Wayland display server, you might get display issues with the RuleWizard. We recommend changing it to X11.
You can verify what display server your Linux distribution is using by:
- Executing the following command in the Linux terminal:
echo $XDG_SESSION_TYPE
(works in most distributions). - Checking the desktop environment settings (not available in all distributions).
- Checking the current setting on the login screen, usually by clicking the wheel/cog/menu icon on the login screen (not available in all distributions; the Automatic Login feature needs to be turned off).
- Checking the Windowing System field on the Settings/About page.
You can change your display server to X11 by:
- Editing the display manager (GDM, SDDM, and so on) configuration file, for example
/etc/gdm3/custom.conf
for Ubuntu with GDM (a reboot is required). - Clicking the wheel/cog/menu icon on the login screen and choosing X11 (not available in all distributions; the Automatic Login feature needs to be turned off).
Customizing Built-In Rules with RuleWizard
With SOAtest Architect Edition and Automation Edition, you can use RuleWizard to customize any rule marked with the following wizard hat + wizard wand icon in the Test Configuration panel’s rules tree:
We strongly recommend that you leave the SOAtest built-in rules intact; rather than modify the built-in rules, duplicate them and modify the duplicates.
To customize a built-in rule in RuleWizard:
- Open the Test Configurations dialog by going to Parasoft > Test Configurations or by choosing Test Configurations in the dropdown menu on the Test Using button on the tool bar.
- Open the Static > Rules Tree tab for any Test Configuration.
- Right-click the rule you want to modify and choose Duplicate. A duplicate rule node—with a file icon—will be added to the rules tree.
- Right-click the duplicate rule and choose Edit Rule in RuleWizard.
The RuleWizard GUI will then open. The RuleWizard User's Guide (accessible by going to Help > Documentation in the RuleWizard GUI) contains information on how to modify and save custom rules. Be sure to save the rule after you modify it, then enable it as described in the Configuring Test Configurations and Rules for Policies or Using Custom Rules.
This procedure is the same across Parasoft Test family products. For details, see the Configuring Test Configurations and Rules for Policies.
Creating New Rules
You can easily create your own static analysis rules (or modify built-in rules) using the SOAtest RuleWizard module, a graphical rule creation and customization tool available in SOAtest (Architect edition) and SOAtest (Automation edition).
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). No coding or knowledge of the parser is required to write or modify a rule.
To open RuleWizard, go to Parasoft > Launch RuleWizard.
The RuleWizard GUI will then open. The RuleWizard User's Guide (accessible by going to Help > Documentation in the RuleWizard GUI) contains information on how to modify, create, and save custom rules.
Before you can check custom rules, you must configure SOAtest to import and check them. For details on how to configure SOAtest to recognize and check those rules, see the Configuring Test Configurations and Rules for Policies or Using Custom Rules.
Note on Rule IDs
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.
Using Custom Rules
Before you can check custom coding rules that were designed in RuleWizard, you need to configure SOAtest to access and check those rules.
To configure SOAtest to import and check custom rules:
- Open the Test Configurations dialog by going to Parasoft > Test Configurations or by choosing Parasoft > Test Configurations in the dropdown menu on the Test Using button on the tool bar.
- Select any Test Configurations category. The new rule(s) will be available in all available Test Configurations.
- Open the Static > Rules Tree tab.
- If any new rules should belong to a new category, create a new category as follows:
- Click Edit Rulemap.
- Open the Categories tab.
- Click New. A new entry will be added to the category table.
- Enter a category ID and category description in the new entry. For instance, an organi-zation might choose to use ACME as the category ID and ACME INTERNAL RULES as the description.
- Click OK to save the new category.
- Click Import to the right of the rules tree. The Import RuleWizard rule dialog will open.
- Use the Import RuleWizard rule dialog to specify which rule(s) you want to import, and whether you want to overwrite existing rule files (if an imported rule file has the same name as an existing rule file).
- Click OK. The rule will be displayed under the assigned category and will be disabled by default.
- Enable the new rule(s) you want checked.
- Click either Apply or Close to commit the modified settings.