Creating a user-defined rule
In addition to the set of code review rules that are shipped with the product, you can create your own rules based on a set of templates. Each template corresponds to a generic rule with a set of empty parameters for which you supply values. Supplying a set of values creates a new rule from the template that can be shared between team members.
To create a rule from a template:
- Click Window > Show View > Other, expand Java, select Code Review, and click OK. The Code Review view opens.
- Click Window > Preferences. The Preferences window opens, showing the Code Review page.
- In the left pane, expand Java , then select Code Review.
- In the Preferences window click New rule. The New Code Review Rule wizard opens and provides templates for the following categories of rules:
- General
- J2EE Best Practices
- On the Select rule template page, click the template you want to use for your rule. When you select a template, the text below the list provides information about the rule you create from it.
- Click Next.
- On the Configure page under Basic properties, specify the following information:
- Category: Accept the default category that the rule is assigned to or click Browse to select a different category. From the list, select the category you want the rule assigned to and click OK.
- Severity Level: Click Problem, Warning, or Recommendation to indicate how strictly you want to enforce the rule.
- Under Specific properties, specify the properties that are dependent upon the template you chose. These properties are unique to your rule, such as a file or class in your own application.
- Click Finish to return to the Preferences window where you see that your rule has been added to the appropriate code review.
Modifying a user-defined rule
Code review rules that are shipped with the product can only be enabled or disabled. However, user-defined rules can be moved into different rule categories, removed, enabled, or disabled.Importing a rule configuration
You can modify and disable rules to create your own rule configuration, and then export or import a rule configuration.Exporting a rule configuration
You can modify and disable rules to create your own rule configuration. You can export that configuration to a file that other team members can import. This allows the team to efficiently share a customized rule configuration to ensure that they run consistent code reviews that apply exactly the same rules and settings.
Parent topic
Configuring code review