9.1.2 CODESCAN Command
This command identifies issues with the code using the Trivadis Coding Guidelines, which is available on GitHub.
Syntax
codescan { -path dir | -format {json|text} | -ignore ruleNo | -output file | -settings file }
where
-path
checks SQL, PLS and PLB files in the directory for SQL Best Practice violations and generates a report of the issues found.-format
formats the output as structured JSON. For example:[ {"file": "/private/tmp/tst.sql", "warnings": [ {line:35, pos:15, ruleNo:"G-1050", msg:"Avoid using literals in your code" },...]... ].
-output
saves the report in a new file.-ignore
skips specified rule checks.-settings
imports CODESCAN settings from the JSON file. Currently, only the ignore attribute is supported, example,{"ignored":["G-1050", "G-4010"]}
.
Set Codescan
Controls warning messages that are triggered for SQLcl command line code quality issues.
Syntax
set codescan {ON | OFF}
where ON
turns on warnings for SQL and PL/SQL best practice violations.
The default is OFF
.
Example
SQL>set codescan on
SQL>BEGIN
BEGIN
null;
END;
END;
/
SQL best practice warning (1,7): G-1010: Try to label your sub blocks
PL/SQL procedure successfully completed.