Built-in code review rules for PL/I
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
ENTRYvariables 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
ENTRYvariables that have differentRETURNSattributes. - 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
BITattribute. It also applies to data items that are declared with theCHARACTERattribute, if theCHARACTERattribute 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 DECIMALvariable 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
BITattribute. - 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
CHARACTERattribute. - 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, orWHENclause that consists of a single variable that is not declared asBIT(1) NONVARYING. - EXEC SQL: Avoid SELECT *
- Use this rule to flag
EXEC SQLstatements that containSELECT *. - EXEC SQL: Use unqualified table names
- Use this rule to flag any
EXEC SQLstatement 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, orOFFSET. - Use INITIAL with STATIC data declarations
- Use this rule to flag data declarations that contain the
STATICattribute but not theINITIALattribute.
- 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
INONLYorNONASSIGNABLEprocedure 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 TOstatements that specify a label in another block. - Avoid GO TO statements that specify a label variable
- Use this rule to flag any
GO TOstatement that specifies a label variable. - Avoid most GO TO statements
- Use this rule to flag all
GO TOstatements, exceptGO TOstatements that transfer control out of a begin-block. - Avoid SELECT statements without OTHERWISE branch
- Use this rule to flag any
SELECTstatement orSELECTdirective that does not contain anOTHERWISEbranch. - Avoid STOP statements
- Use this rule to flag all
STOPstatements. - 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 CICScommand.Use this rule to flag a comparison between such a data item and anything other than the return value of aDFHRESPfunction call. This rule applies to comparisons in the following contexts:- In any relation condition
- In any
WHENunit of aSELECTstatement in which the data item is the selection subject
- EXEC CICS: Use the RESP option
- Use this rule to flag
EXEC CICScommands that do not include the RESP option.This rule examines all
EXEC CICSblocks 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
INITattribute is not specified for the locator variable, orINIT(NULL)orINIT(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
SIZEorSTORAGEbuilt-in function. - An
- Use a label with procedure END statements
- Use this rule to flag a procedure
ENDstatement 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
IFstatement that contains anELSEunit in whichELSEis immediately followed by anotherIFstatement.The
IFstatement is not flagged if it is contained within anotherIFstatement 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.