Verissimo SystemVerilog Testbench Linter User Guide
Rev. 24.1.6, 27 March 2024

15.4 Overriding Rules in the Ruleset XML File

You can split a Verissimo ruleset across several ruleset XML files by means of the <include> tag. A typical use-case is to enforce a generic ruleset for all projects, but still allow project-specific customization by adding or overriding specific rules.

For example you could have a ruleset XML with global rules that should be generally applied for all projects and another ruleset XML with group or project specific rules, both of them included in the main Verissimo ruleset XML file.

<?xml version="1.0" encoding="UTF-8"?>
<ruleset version="2" name="Main Ruleset" library="UVM">
   <include relative="true" file="global_rules.xml" />
   <include relative="true" file="project_rules.xml" />
</ruleset>

To change parameters of a rule from the the global_rules.xml, you can use the override-rule tag in the project_rules.xml. For example let's assume you have the following rule in the global rules file:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<ruleset version="2">
   <category name="Banned Old API">
      <rule
         id="SVTB.29.1.0"
         name="Banned methods"
         description="Do not use old API methods.">
             <property
                 key="bannedMethods"
                 value="old_api_method1, old_api_method2, old_api_method3"
             />
      </rule>
   </category>
</ruleset>

Its description and bannedMethods parameters can be overridden with the following override-rule tag in the project ruleset file:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<ruleset version="2">
   <category name="Banned Old API">
      <override-rule
         name="Banned methods"
         description="Do not use old API methods. Until full transition to new API, only use of old_api_method1 is allowed.">
             <property
                 key="bannedMethods"
                 value="old_api_method2, old_api_method3"
             />
      </override-rule>
   </category>
</ruleset>

You can even define multiple rule overrides, and each rule override can specify one or more of the rule's attributes: description, parameters, title, severity, etc.

Note that the order of rules and their subsequent rule overrides is important, with the last rule override having highest precedence. Typically you would include a ruleset XML containing overrides at the end of the main ruleset XML file.

Keep in mind the override-rule must match the name of the rule you wish to override ( not the id).

You can also specify that a rule cannot be overridden by adding the allow-override="none" attribute to the rule tag, thus making it read-only:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<ruleset version="2">
   <category name="Banned Old API">
      <rule
         id="SVTB.29.1.0"
         name="Banned methods"
         description="Do not use old API methods."
         allow-override="none" >
             <property
                 key="bannedMethods"
                 value="old_api_method1, old_api_method2, old_api_method3"
             />
      </rule>
   </category>
</ruleset>

You can even disable a rule by adding the disable="true" attribute in the rule override.