Chapter 4. Overriding rules

download PDF

You can override core rules distributed with MTA or even custom rules. For example, you can change the matching conditions, effort, or hint text for a rule. This is done by making a copy of the original rule, marking it as a rule override, and making the necessary adjustments.

You can disable a rule by creating a rule override with an empty <rule> element.

4.1. Overriding a rule

You can override a core or custom rule.


  1. Copy the XML file that contains the rule you want to override to the custom rules directory.

    Custom rules can be placed in <MTA_HOME>/rules, ${user.home}/.mta/rules/, or a directory specified by the --userRulesDirectory command-line argument.

  2. Edit the XML file so that it contains only the <rule> elements for the rules that you want to override.


    Rules from the original ruleset that are not overridden by the new ruleset are run as normal.

  3. Ensure that you keep the same rule and ruleset IDs. When you copy the original rule XML, this ensures that the IDs match.
  4. Ensure that the target technology in the override ruleset matches one of the targets that you specified for running the analysis.
  5. Add the <overrideRules>true</overrideRules> element to the ruleset metadata.
  6. Update the rule definition.

    You can change anything in the rule definition. The new rule overrides the original rule in its entirety.

The following rule override example changes the effort of the weblogic-02000 rule in the weblogic ruleset from 1 to 3:

Rule override definition example

<?xml version="1.0"?>
<ruleset id="weblogic"
    xsi:schemaLocation=""> 1
        <overrideRules>true</overrideRules> 2
        <rule id="weblogic-02000" xmlns=""> 3
                <javaclass references="weblogic.utils.StringUtils.{*}"/>
                <hint effort="3" category-id="mandatory" title="WebLogic StringUtils Usage"> 4
                    <message>Replace with the StringUtils class from Apache Commons.</message>
                    <link href="" title="Apache Commons Lang"/>

Ensure that the ruleset id matches the original ruleset id.
Add <overrideRules>true</overrideRules> to the <metadata> section.
Ensure that the rule id matches the original rule id.
Updated effort.

When you run MTA, this rule overrides the original rule with the same rule ID. You can verify that the new rule was used by viewing the contents of the Rule Provider Executions Overview.

4.2. Disabling a rule

To disable a rule, create a rule override definition with an empty <rule> element according to the following example:

Rule override definition example to disable a rule

<?xml version="1.0"?>
<ruleset id="weblogic"
        <rule id="weblogic-02000" xmlns="">

The <rule> element is empty so that the weblogic-02000 rule in the weblogic ruleset is disabled.
Red Hat logoGithubRedditYoutubeTwitter


Try, buy, & sell


About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.