PL/SQL Cop

 

Version 2.1.6
Last Update 2018-09-10
License valid thru 2019-03-31
File size 63.3 MB
Downloads 2,335

Introduction

Trivadis PL/SQL Cop is a command line utility to check Oracle SQL*Plus files for compliance violations of the Trivadis PL/SQL & SQL Coding Guidelines Version 3.2.

Furthermore McCabe’s cyclomatic complexity, Halstead’s volume, the maintainability index and some other software metrics are calculated for each PL/SQL unit and aggregated on file level.

The code checking results are stored in XML, HTML and Excel files for further processing.

To get the most out of this command line utility you should make it part of your Continuous Integration environment by using the PL/SQL Cop for SonarQube plugin. This way you may control the quality of your code base over time.

Have also a look at PL/SQL Cop for SQL Developer if you are interested to check the code quality of PL/SQL code within SQL Developer. It’s a free extension.

Examples

Here are some screen shot taken from an of an HTML report based on the samples provided with PL/SQL Cop.

These HTML and Excel reports have been created by PL/SQL Cop and are based on a simple set of good and bad example files distributed with PL/SQL Cop.

Custom Guidelines as PL/SQL Cop Plugins

Since version 2.0 PL/SQL Cop supports custom validators. Such a validator must implement the PLSQLCopValidator Java interface and has to be a direct or indirect descendant of the PLSQLJavaValidator class. To simplify the development of a validator an example is provided as Maven project. This example validator implements 15 guidelines to cover the chapter 2.2 Naming Conventions of the Trivadis PL/SQL & SQL Coding Guidelines Version 3.2. The following screenshot shows how checks are implemented.

 

PL/SQL Editor for Eclipse

The following screenshot shows the test case for the checkConstantName method. The outline of the editor reveals the class name to be used for the check.

The editor is mainly provided to understand the PL/SQL model better. The full model is available as PLSQL.ecore file, which may be explored best within the Eclipse IDE.

Further Information

Please find further information about PL/SQL Cop on the Trivadis website.