This topic describes the custom rule templates supported
for the COBOL language.
See Working with custom rules.
- An inline PERFORM statement cannot exceed the specified line number
limit
- Use this template to flag PERFORM statements that contain more
than a specified number of lines. Enter the number of lines as a parameter
to this template.
Note that the template counts the nonblank lines
following PERFORM and before END PERFORM.
- Avoid calling the specified routine
- Use this template to flag CALL statements that call a specified
routine. Enter the name of the routine as a parameter to this template.
Note
that this template is enforced only when the CALL statement uses the
literal name of the routine.
- Avoid including the specified copy book
- Use this template to flag COPY statements that refer to a specified
copy book. Enter the name of the copy book as a parameter to this
template.
- Avoid nesting IF statements deeper than the specified number of
levels
- Use this template to flag IF statements that are nested deeper
than a specified number of levels. Enter the number of levels of
nesting as a parameter to this template.
Note that if the nesting
is more than one level deeper than the specified maximum then the
template flags only the outermost nested IF statement.
Compare
the rule Use EVALUATE statement rather than nested IF statement.
- Avoid static calls except for the specified program name
- Use this template to flag CALL statements in which (a) a Java™ static method or a COBOL factory
method is called, and (b) the method name does not match the specified
program name. Enter the program name as a parameter to the template.
- Avoid using the selected compiler directives
- Use this template to flag the selected compiler directives. Select
the compiler directives to flag: BASIS, CBL (PROCESS), COPY, EJECT,
REPLACE, SERVICE LABEL, SERVICE RELOAD, SKIP, and TITLE.
- EXEC SQL: Use a WHERE clause in selected statements
- Use this template to flag any EXEC SQL statement containing a
SELECT, DELETE, or UPDATE statement that does not include a WHERE
clause. Select the types of statement to flag: SELECT, DELETE, and
UPDATE.
- Follow the specified naming convention for COBOL file names
- Use this template to flag program file names that do not match
a specified regular expression. Enter the regular expression as a
parameter to this template. The comparison ignores the file extension
of the program name, if any.
Examples:
- To flag file names that do not begin with "prefix" use: ^prefix.*$
- To flag file names that do not begin with "prefix" and end with
an integer use: ^prefix.[0-9]$
The regular expression must have one match only for its
target file names, starting with the first character of the file name
and ending with the last. For example, to match files beginning with
AARV, such as AARVLIST.cbl, AARVUPDT.cbl, AARVEDIT.cbl, and so on.
- Correct example: ^aa.*$
- Incorrect example: a
The first example is correct because it matches the names AARVLIST,
AARVUPDT, and so on only once, and it matches them from the first
character to the last. The second example is incorrect because it
matches the names AARVLIST, AARVUPDT, and so on more than once (at
index 0 and at index 1) and it does not match them from the first
character to the last.
- Procedure division statements cannot exceed the specified line
number limit
- Use this template to flag PROCEDURE divisions that contain more
than a specified number of lines. Enter the number of lines as a
parameter to this template.
During processing
the template counts all the nonblank lines in the PROCEDURE division
after the procedure division header.
- Use a scope terminator phrase with the specified COBOL statement
type
- Use this template to flag the specified type of COBOL statement
if it does not contain a scope terminator phrase. Select the type
of COBOL statement as a parameter for the template.
The statement
types are CALL, IF, EVALUATE, READ, SEARCH, or STRING.
- Use comments to describe all paragraphs
- Use this template to flag paragraph declarations that are not
immediately preceded or followed by a comment. Select whether the
comment precedes or follows the paragraph declaration.
A paragraph
declaration is a paragraph name or paragraph header that begins a
paragraph.
- Use comments to describe all sections
- Use this template to flag section headers that are not immediately
preceded or followed by a comment. Select whether the comment precedes
or follows the section header.
- Use the specified prefix with condition names
- Use this template to flag data descriptions that do not begin
with the specified prefix. Enter the prefix as a parameter to the
template.