Custom rule builder

The core code review and quality control engine analyses PL/SQL code against over 180 standardised code review rules and allows creating custom requirements in XPath.

Follow this guide to create custom rules for code analysis.
To create a custom code review rule, the user should be familiar with the XML Path Language (XPath). To learn the XPath syntax, refer to the external resources and
Let's consider the following example:
  • Use case
    The package SOME_CUSTOMER_DEPRECATED_PACKAGE has been deprecated.
    Make sure the package SOME_CUSTOMER_DEPRECATED_PACKAGE is no longer used in the code.
Go to Options > Code Analyzer Options > Code Review Options, and click Add New. The Code Review Rule Editor will open.
Enter the code review name.
For example: Avoid use of SOME_CUSTOMER_DEPRECATED_PACKAGE package.
Select a severity level — Major, category — Maintainability, code element — PL/SQL.
On the Rationale subtab, enter a short description of the rule's usage.
For example:

<p>The company has deprecated the SOME_CUSTOMER_DEPRECATED_PACKAGE package. 
Do not use this package.</p>

Switch to the XPath Expressions and Code Sample tab.
Enter an XPath expression:

//subprogram_call[compound_name[@identifier = 'SOME_CUSTOMER_DEPRECATED_PACKAGE']]

Enter a code sample to check how the rule works in practice:

** SOME_CUSTOMER_DEPRECATED_PACKAGE should not be used any longer!

XML source code will be created automatically once the code sample is ready.
Click a big green arrow or press F9 to run the XPath expression. Query results will be shown below, including the detected violation(s).
Code Review Rule Editor
Fig 1 - Code Review Rule Editor
Click OK to save the rule and close the window. Get back to the main page, and re-run a project analysis to apply the rule.
Want to share your code review rules with the team? Save them to PDF:

  1. Use Ctrl+Click to select rules you would like to save to a PDF-file.
  2. Click Print Preview on the pop-up menu of the Code Review Options page.
  3. Click Save to PDF in the print preview dialog box.
This document was last updated on February 20, 2020