The Code Review component supports built-in
code review rules for PL/I.
These rules are built into the Code Review
for PL/I component and do not require parameters. You can select these
rules from the Naming Conventions, Performance, and Program Structures
categories in the software analysis configuration window.
For more information about using this window, see Creating a software analysis configuration.
- Naming Conventions:
- Use a level number when declaring data
- Use this rule to flag any declared data item that does not contain
a level number.
- Use a main procedure name that matches the source file name
- Use this rule to flag a main procedure whose name does not match
the source file name.
- Performance:
- Avoid assigning or comparing two entry variables having different
parameter lists
- Use this rule to flag any assign or compare of two ENTRY variables
that have different parameter description lists.
- Avoid assigning or comparing two entry variables having different
RETURNS attributes
- Use this rule to flag any assign or compare of two ENTRY variables
that have different RETURNS attributes.
- Avoid comparisons of BIT strings of different length
- Use this rule to flag any expression that contains a comparison
of two BIT strings of unequal lengths.
This rule applies to bit
constants and to data items that are declared with the BIT attribute. It also applies to data items that are declared with
the CHARACTER attribute, if the CHARACTER attribute
is followed by a VALUE attribute set to a bit constant value. It
does not apply to implicitly declared variables or to the results
of nested expressions.
- Avoid declaring multiple data items by factoring attributes
- Use this rule to flag data declarations that declare multiple
data items by factoring attributes. For example: declare
(A,B,C,D) binary fixed (31);
- Avoid FIXED DECIMAL declarations with even precision
- Use this rule to flag any declaration of a FIXED DECIMAL variable
that specifies an even number of digits.
- Avoid implicit declarations
- Use this rule to flag references to data items that are not explicitly
declared.
- Avoid using data elements of type BIT in arithmetic operations
- Use this rule to flag any data element in an arithmetic expression
or built-in arithmetic function that is declared with the BIT attribute.
- Avoid using data elements of type CHARACTER in arithmetic operations
- Use this rule to flag any data element in an arithmetic expression
or built-in arithmetic function that is declared with the CHARACTER attribute.
- Avoid using the PROCESS directive
- Use this rule to flag a PROCESS directive.
- Declare a single variable in an IF, WHILE, UNTIL, or WHEN clause
as BIT(1) NONVARYING
- Use this rule to flag any IF, WHILE, UNTIL,
or WHEN clause that consists of a single variable
that is not declared as BIT(1) NONVARYING.
- EXEC SQL: Avoid SELECT *
- Use this rule to flag EXEC SQL statements that
contain SELECT *.
- EXEC SQL: Use unqualified table names
- Use this rule to flag any EXEC SQL statement
that contains a table name that is qualified or that is not explicitly
specified.
- Use a loop control variable that is FIXED BINARY, FLOAT, ORDINAL,
HANDLE, POINTER, or OFFSET
- Use this rule to flag any loop condition whose loop variable is
not FIXED BINARY, FLOAT, ORDINAL, HANDLE, POINTER,
or OFFSET.
- Use INITIAL with STATIC data declarations
- Use this rule to flag data declarations that contain the STATIC attribute
but not the INITIAL attribute.
- Program Structures:
- Avoid assigning a value to an INONLY or NONASSIGNABLE parameter
- Use this rule to flag any statement that assigns a value to an INONLY or NONASSIGNABLE procedure
parameter.
- Avoid ending a comment after column 72
- Use this rule to flag any comment that contains a line that extends
past column 72.
- Avoid GO TO statements that specify a label in another block
- Use this rule to flag all GO TO statements that
specify a label in another block.
- Avoid GO TO statements that specify a label variable
- Use this rule to flag any GO TO statement that
specifies a label variable.
- Avoid most GO TO statements
- Use this rule to flag all GO TO statements, except GO
TO statements that transfer control out of a begin-block.
- Avoid SELECT statements without OTHERWISE branch
- Use this rule to flag any SELECT statement
or SELECT directive that does not contain an OTHERWISE branch.
- Avoid STOP statements
- Use this rule to flag all STOP statements.
- Avoid using characters except for sequence numbers after column
72
- Use this rule to flag any line that contains characters after
column 72 that are not sequence numbers.
- EXEC CICS: Use DFHRESP to check the return value
- This rule applies to data items that are used as the RESP or RESP2 parameter
of an EXEC CICS command.
Use
this rule to flag a comparison between such a data item and anything
other than the return value of a
DFHRESP function
call. This rule applies to comparisons in the following contexts:
- In any relation condition
- In any WHEN unit of a SELECT statement
in which the data item is the selection subject
- EXEC CICS: Use the RESP option
- Use this rule to flag EXEC CICS commands
that do not include the RESP option.
This rule
examines all EXEC CICS blocks
and checks that a RESP() option is present. If
no option is present, the block is flagged as a violation.
- Initialize locator variables used for based storage
- Use this rule to flag all references to a based data item for
which the locator variable might not be initialized.
This rule
concludes that the locator variable might not be initialized if all
the following conditions are true:
- An INIT attribute is not specified for the locator
variable, or INIT(NULL) or INIT(SYSNULL) is
specified.
- No assignment statement sets the value of the locator variable.
- No allocate statement explicitly or implicitly sets the value
of the locator variable.
- No allocate statement sets the value for any data item that uses
the locator variable as a base.
This rule does not flag a reference to the based data
that is an input parameter of the SIZE or STORAGE built-in
function.
- Use a label with procedure END statements
- Use this rule to flag a procedure END statement
that does not have a label or that has a null label. This rule applies
to both nested and unnested procedures.
- Use a SELECT statement rather than ELSE-IF
- Use this rule to flag any IF statement that contains
an ELSE unit in which ELSE is immediately
followed by another IF statement.
The IF statement
is not flagged if it is contained within another IF statement
that is already flagged for a rule violation.
- Use dot qualified references to structure members that are not
level 1
- Use this rule to flag non-dot-qualified references to structure
members that are not level 1.