Rule sets
Required role | Rule Management |
Access | CodeChecker Server → Rules Configuration → Rule Sets |
The Quality rules used to analyze the source code of an application are grouped into rule sets in the CodeChecker Studio.
Use rule sets to organize quality rules in a logical way: by language, by theme, and so on. The standard quality rules are already organized into several generic rule sets. You can create new rule sets to manage and categorize your custom quality rules, or re-organize the standard quality rules to fit your needs.
A rule set must be activated to be used.
ARCAD CodeChecker supplies a number of standard, ready-to-use rule sets, that include all the elements required for their configuration (quality rules, metrics and validation expressions)
For more information about individual quality rules, refer to Quality rules.
The Rule Sets search view is accessed from the Configuration node in the Navigator.
Enter any combination of the above search criteria, then click the Search button to display the results. To display the complete list, click the Search button without entering any search criteria.
Follow the subsequent steps to create a new rule set.
Step 1 To access the Create Rule Set wizard, either click the Create icon in the toolbar of the Rule Sets search view, or right-click anywhere in the list of the view and select Create Rule Set.
You can also create a new rule set by right-clicking on an existing one and selecting the Duplicate Rule Set option, or select a rule set and click the Duplicate Rule Set icon in the toolbar.
Step 2 Define the rule set's Code and Name. These values are required to create a new rule set but can be edited later.
If the new rule set is created by duplicating an existing one, edit its Code and Name values.
Click Finish.
Result The new rule set is created and is activated automatically. It is displayed in the search list in the Rule Sets search view.
New sets do not contain any quality rules yet and must be edited before they can be used.
To open a rule set's editor, locate it in the Rule Sets search view, then either:
- double-click on the item in the view,
- right-click on the item in the view and select Edit, or
- select the item in the view and click the Edit icon in the toolbar.
The editable values are all located in the Rule Set tab in the rule set's editor. The Code Reviews tab displays the list of code reviews that include this rule set. Double-click on a code review to access its editor.
Save the changes (, Ctrl+S
or File > Save).
- Code
- This code is the rule set's ID. The code can be the same value as the Name but must be unique among other rule sets.
- Name
- The rule set's name should reflect a category or the type of quality rules that are contained in it to be easily identified.
- Description
- [Optional] Enter a detailed description of the rule set. This description is displayed in the ARCAD CodeChecker plug-in for RDi to provide additional information.
- Activated
-
When this box is checked, the rule set. A rule set must be active to be used in a code review or in the ARCAD CodeChecker plug-in for RDi.
ReferenceFor more information about activating rule sets, refer to Activating rule sets.
This section enables you to manage the quality rules included in the rule set.
Follow the subsequent steps to add quality rules to a rule set.
Step 1 Open the desired rule set in the Rule Sets view.
Step 2 Click the Add button. The Select Quality Rules wizard opens.
Select one or several [Ctrl+click]
quality rule(s) from the list.
To filter the list of quality rules displayed in the Select Quality Rules dialog and make finding the correct quality rule easier, use the Filter field at the top of the dialog. You can also use the tick-boxes to restrict the rule search to a specific language. Both filtering methods can be combined. The list of quality rules is updated automatically to match the defined filters.
You can also copy and paste rules from one rule set to another, or directly from the Quality Rules view, by right-clicking on a rule and selecting the Copy or Cut option. You can then open another rule set, right-click and select the Paste option. You can use the following keyboard shortcuts: Ctrl + C
, Ctrl + X
and Ctrl + V
.
Click OK.
Only active quality rules can be added to a rule set. The quality rules that are not yet activated will not be displayed in the Select Quality Rules wizard.
For more information about activating quality rules, refer toActivating quality rules.
Result The selected quality rules are added to the rule set.
To remove a quality rule from a rule set, either right-click on the quality rule in the list in the Rule Set editor and select Remove, or select the rule(s) [Ctrl+click]
and click the Remove button.
Required role | Activation |
Activating a rule set means this rule set can be used in a code review or in the ARCAD CodeChecker plug-in for RDi.
To activate a rule set, check Activated in the rule set's editor.
If a rule set is not active, it is considered deactivated and cannot be used. The quality rules included in a deactivated rule set cannot be executed either.
Single quality rules can also be activated or deactivated. Deactivated rules, even if they are included in an activated rule set, cannot be executed either.
ARCAD CodeChecker has a set of default rule sets available. The rule sets are loaded when the CodeChecker Server starts. The default rule sets contain all the configuration elements (quality rules, metrics, metric models, validation expressions) required to get started with general code quality.
You can update the default rule sets to benefit from all the latest code quality tools ARCAD offers. To load the default rule sets, right-click on the CodeChecker Server and select the Reload default Rule Sets option, or click the Reload default Rule Sets icon in the Navigator toolbar. A dialog opens, you can choose to duplicate the ones already present (Duplicate), leave out the existing entities (Only new) or overwrite existing entities (Overwrite). A confirmation dialog then opens to list the number of elements successfully loaded.
To open the rule sets documentation in a web page, click on the Documentation icon in the toolbar. You can also right-click anywhere in the list of rule sets and select the Open the Rule Sets documentation option.
The documentation for all the rules is displayed in a web-browser, including your custom rules and rule sets.
Exporting and importing rule sets is useful when sharing configurations between multiple servers or users.
A rule set's exported configuration includes its dependent entities as well as the properties and definitions associated with these entities, maintaining the relationships between them.
All the original configuration that came from the exported entities are retrieved when importing the rule set again in ARCAD CodeChecker.
An exported rule set may include:
- quality rules,
- metrics,
- metric models,
- validation expressions.
The CodeChecker Server comes with default rule sets to populate all the default configuration elements (rule sets, metrics, etc.).
Follow the subsequent steps to export a rule set to a .json file.
Step 1 Select the rule set(s) to export. Click the Export icon in the toolbar of the Rule Sets search view, or right-click and select Export in the menu.
Step 2 Select the location in which to save the exported file(s) and change the file name(s), if needed.
By default, rule sets are exported with the file name: ARCAD_CodeChecker.json.
Click Save.
Result The rule set's configuration is available externally and can be imported as such for other ARCAD CodeChecker servers or users.
Follow the subsequent steps to import a rule set from a .json file.
Step 1 Click the Import icon in the Rule Sets search view, or right-click anywhere in the view and select Import.
Step 2 Select the import file. Click Open.
ARCAD CodeChecker detects the items on the server that share the same code (ID) as the one from the import file.
Step 3 Depending on the content of the import, you may choose to duplicate the ones already present (Duplicate), leave out the existing entities (Only new) or overwrite existing entities (Overwrite).
- Duplicate: the conflicting objects are imported as duplicates of existing objects with different codes.
- Only new: the conflicting objects are ignored (new objects are imported).
- Overwrite: the conflicting objects are imported (existing objects are replaced).
Result The imported rule set(s) and related entities are displayed in their respective search views.
Deleted rule sets cannot be accessed or recovered.
To delete a rule set, either right-click on it in the Rule Sets search view and select Delete, or select it and click the Delete icon in the toolbar. Click OK to confirm or click Cancel to keep the rule set.