Chapter 6. Adding custom rules

By default, the IDE plugin comes with a core set of system rules for identifying migration and modernization issues. You can browse the existing rules from the IDE plugin.

You can create your own rules for identifying issues specific to your applications. You can either import an existing custom ruleset or create a custom ruleset directly in the IDE plugin.

6.1. Browsing rules

You can view both system and custom rules from the IDE plugin.

  1. From the MTA perspective, open the Rulesets tab.
  2. Expand the System item to view core system rules, or expand the Custom item to view custom rules.

    Note

    In order to view system rules, the MTA server must be started.

  3. Expand the ruleset containing the rule you want to review.
  4. Double-click the rule to open the rule in a viewer. You can select the Source tab to view the XML source of the rule.

6.2. Importing a custom ruleset

You can import an existing custom ruleset into the IDE plugin to use during analysis of your projects.

  1. From the MTA perspective, open the Rulesets tab.
  2. Click the import ruleset icon ( Import ruleset icon ).
  3. Browse to and select the XML rule file to import.

    Note

    The XML rule file must use the .windup.xml or .mta.xml extension in order to be recognized as an MTA rule.

  4. The custom ruleset is now shown under the Custom item in the Rulesets tab.

This custom ruleset can now be selected in run configurations when analyzing projects.

See the Rules Development Guide to learn more about creating custom XML rules.

6.3. Creating a custom ruleset

You can create a new custom ruleset in the IDE plugin to use during analysis of your projects.

Procedure

  1. From the MTA perspective, open the Rulesets tab.
  2. Click the create ruleset icon ( Create ruleset icon ).
  3. Select the project and directory to save the new ruleset in.
  4. Enter the file name for the ruleset file.

    Note

    The XML rule file must use the .windup.xml or .mta.xml extension in order to be recognized as an MTA rule.

  5. Enter a ruleset ID, for example, my-ruleset-id.
  6. Optionally, check the Generate quickstart template checkbox to add basic rule templates to the ruleset file.
  7. Select Finish.
  8. The new ruleset file opens in an editor and you can add and edit rules in the file. You can also select the Source tab to edit the XML source for the ruleset file.

This new ruleset can now be selected in run configurations when analyzing projects.

See the Rules Development Guide to learn more about creating custom XML rules.

6.4. Submitting a custom ruleset

You can submit your custom ruleset for inclusion in the official MTA rule repository. This allows your custom rules to be reviewed and included in subsequent releases of MTA, enhancing the applications and server configurations that MTA analyzes.

Procedure

  1. From the MTA perspective, click the Rulesets tab.
  2. Click the dropdown icon ( Dropdown ) and select Submit Ruleset.
  3. Complete the following fields:

    • Summary: Describe the purpose of the rule. This becomes the title of the submission.
    • Code Sample: Enter an example of source code that the rule should run against.
    • Click Choose Files and navigate to the saved rule to attach it.
    • Description: Enter a brief description of the rule.
  4. Click Submit.





Revised on 2021-07-11 10:24:59 UTC