You can create a ruleset file with the definitions of what rules should be checked using the Main menu:
Tools ⇒ Codescan Apex Ruleset Configuration.
This window gives a few options to flexible manage CodeScan settings. You're able to:
- open and edit any existing CodeScan ruleset,
- create a new empty ruleset and configure it to exactly fit your needs,
- create a ruleset using the default Villagechief (CodeScan creators) template, where a lot of rules are already pre-configured, however, you still have the full freedom to modify it as you want.
Editing an existing ruleset
If you've already created a ruleset and you want to modify it, click on the Open button. In the opened window, select a folder, where the ruleset's file is located, select the file, and click the Open button. Your ruleset will be loaded, and you'll be able to change it as you want.
Creating a new empty ruleset
To create a new ruleset, click on the 'New button and select the New Empty Ruleset option. In the opened window you'll get the list of all the available rules in 18 categories. First off, enter a name and description for a new ruleset on the right side, these fields are required. Also, you can specify files, that needs to be excluded from the scanning list, or backward – obviously included.
On the left side, there are all the rules combined into categories. Next to the category name, there is a number of enabled rules with a total number of rules in a category. Expand a category to see the rules it includes. Click on a necessary rule, you will get the information about it in the right part of the window. On the right side of the configurator, you will see the configuration details for a selected rule. Then, depending on the rule itself, you might be able to configure different parameters so it will match your vision of good code.
The parameters for a CodeScan rule are combined into the following categories:
- Attributes — priority of a rule and a message for it.
Priority for a rule can be the next:
- 1 – change is absolutely required,
- 2 – change is highly recommended,
- 3 – change is recommended,
- 4 – change is optional,
- 5 – change is highly optional.
- General — the settings for configuration each rule.
Above the list of rules, you can find a filter, that will help you to find a necessary one in a few seconds. Just start typing, and the list will be shortened to fit your request.
Set all the necessary values in the appropriate fields and click the Save ruleset button at the top of the window.
You can always revert all your changes in any ruleset: click on the Reset ruleset button at the top of the window.
Creating a ruleset from a template
You're also able to use a pre-installed CodeScan template for creating your own rulesets.
To create a ruleset from a template, follow the way:
New ⇒ Apex Villagechief Template.
Modify all necessary fields and click the Save button. In case if you want to revert all your changes in a ruleset, click the Reset ruleset button.
In addition, you can also custom XPath rules to your rulesets directly from the IDE. With the custom rules support you will be able to precisely craft your own ruleset according to your personal or team preferences and policies regarding code quality. To do so, click the Add rule button.
In this section:
This also may be useful: