Creating custom rule categories and rules for static analysis

In IBM® Rational® products, you can create custom rule categories and custom rules to add to an analysis configuration in addition to those supplied by analysis providers. For example, a Java™ development team might use a specific set of providers, rule categories, and rules defined in a custom rules file to analyze source code.

To create custom rule categories and rules:
  1. Click Window > Preferences; then click Analysis > Custom Rules and Categories.
  2. To add a custom rule category, on the Custom Rules and Categories page, click Add Category.
  3. In the Add Custom Category window, click a parent for your custom rule category, and click Next.
  4. Type a name for the new category.
  5. Click Finish and verify that the new rule category is listed in the Current® Custom Categories tree.
  6. On the Custom Rules and Categories page, click Add Rule.
  7. In the Add Custom Rule window, click the category to which you want to add your custom rule and click Next.
  8. Click the rule template to use as a basis for the new rule and click Next. Not all forms of analysis support custom rules, but the Code Review for Java domain provides several templates on which you can base your custom rules. To create a custom rule to add to a Java code review, depending on the rule template that you select, you must provide some or all of the following information:
    • The fully qualified class name for the new rule. For example, java.lang.String
    • The name of the method that detects method invocations in the source code
    • The number of arguments that the method uses
    • A severity level for the new rule (recommended, warning, severe)
  9. Click Finish and verify that the new rule is listed in the Current Custom Rules tree.
Related concepts
Static analysis
Rules and rule categories for static analysis