Rational Programming Patterns provides rules in Software
Analyzer to perform the most common controls on generated COBOL files.
Implementation
Before invoking the analysis
of the COBOL code, open the Software Analyzer Configurations dialog
to define a configuration rules set and specify the following information:
- The scope (analyze the entire workspace, a working set or one
or more selected projects).
- The COBOL rule set. You can change the severity for each rule
(recommendation, warning, or severe).
To start the analysis, right-click a selected file or
project. Select Software Analyzer and the rule
set previously defined. The Software Analyzer Results view
displays the list of the broken rules in a tree-like structure. The
first level represents the category, the second level is the rule,
and the last level lists the instances in error. To see the details
of a violation, right-click the file and select View Result .
The COBOL file opens up in the editor where the violation was detected
and the line in violation is highlighted.
After correcting the
violations and saving, you can start the analysis again to check that
all the rules are respected.
For a complete documentation on
the Software Analyzer, see the Rational Developer for System z online
help, in the COBOL Code Review item of the Developing section.
Design Entities Analysis
Software Analyzer
provides analysis support for the Rational Programming Patterns design
entities.
There are three categories of rules that identify
problems related to the design of entities:
- The All Entities category contains the
following rules:
- A non blank label is mandatory on design entities
- At least one keyword is mandatory on design entities
- The Generated Entities category contains
the following rule:
- A generated entity must have its name and external name equivalent
- The Segment Entities category includes
the following rules:
- A Segment must use only defined Data Elements
- Avoid calling the same Data Element multiple times in a Segment
Specific COBOL Code Review
Software Analyzer
provides rules that apply only to the specific code inserted by the
user in a generated COBOL program.
The Rational Programming
Patterns rules can be differentiated from the Rational Developer for
System z standard rules because they are all prefixed by RPP
/.
There are four categories of RPP rules. The Pattern
Driven Programming rules are specific and have no equivalent in Rational
Developer for System z.
However, the rules of Naming
Conventions, Performance, and Program Structures are equivalent to
the rules existing in Rational Developer for System z, but they restrict
the control to specific code portions.
- The RPP / Naming Conventions category contains
a rule that identifies problems related to naming conventions:
- RPP / Use a program name that matches the source file name
- Use this rule to flag any PROGRAM-ID division whose program name
is different than its source file name. The file extension, if any,
of the source file is executed from the comparison.
- The RPP / Pattern Driven Programming category
includes rules that identify problems related to specificities of
the product:
- RPP / Avoid SYNCPOINT statement in Screen entities
- Use this rule to ensure that the SYNCPOINT statement is not used
in the Screens.
- RPP / CALL statement must be in function F97 or F99
- Use this rule to ensure that the CALL statement is used in F97
and F99 only. The rule does not apply to Macros.
- RPP / Never modify a line in IDENTIFICATION or ENVIRONMENT DIVISION
- Use this rule to ensure that no line of specific code is present
in IDENTIFICATION or ENVIRONMENT DIVISION of Program or Screen. The
rule does not apply to Macros.
- RPP / Never override a generated line
- Use this rule to ensure that no line of generated code, including
code from a Macro, is overridden.
- RPP / Never override a generated physical access to a Segment
- Use this rule to ensure that there is no override of automatic
access function in F80 in a Screen. The rule does not apply to Macros.
- RPP / Never override a line coming from a Macro
- Use this rule to check that no line coming from a Macro is overridden.
- RPP / User code must be in a user function.
- Use this rule to check that any block of specific code is inserted
into a specific function. The specific code block starts with the
label FXXXX and ends with the
label FXXXX-FN.
If a specific code line is inserted into a function that is generated
or in a function that comes from a Macro, the rule is broken.
- RPP / User functions must have a non-blank comment
- Use this rule to check that any function added in specific code
is preceded by a comment line that is not empty. There must be at
least one character between column 8 and column 72.
- The RPP / Performance category includes
rules that identify problems related to performance:
- RPP / Avoid the EXEC CICS LINK command
- Use this rule to flag LINK commands in a Program or a Screen.
The rule does not apply to Macros.
- RPP / Avoid INITIALIZE statement. Use elementary MOVE statements
or VALUE clauses.
- Use this rule to flag INITIALIZE statements.
- RPP / Avoid OCCURS DEPENDING ON phrase
- Use this rule to flag OCCURS DEPENDING ON phrases.
- RPP / Avoid using subscripts to access a table. Use indexes.
- Use this rule to flag any data element item that is used as a
subscript to access a table element, and that is not specified in
an INDEXED BY phrase in the OCCURS clause that defines the table.
Note that this rule does not flag subscripts that are literals.
- RPP / EXEC SQL: Avoid SELECT *
- Use this rule to flag EXEC SQL statements that contain a SELECT
* statement.
- RPP / EXEC SQL: Use an ORDER BY clause when declaring a cursor
- Use this rule to flag EXEC SQL statements that declare a cursor
without specifying an ORDER BY clause in the contained SELECT statement.
- RPP / Specify 0 RECORDS for BLOCK CONTAINS clauses in file description
entries
- Use this rule to flag BLOCK CONTAINS clauses that do not specify
0 RECORDS.
- RPP / Use an EVALUATE statement rather than nested IF statement
- Use this rule to flag nested IF statements. Note that if the nesting
is more than one level deep then the flags only the outermost nested
IF statement.
- RPP / Use an odd number of digits in a COMP-3 or PACKED-DECIMAL
data definition
- Use this rule to flag any data definition that is declared as
type COMP-3 or PACKED-DECIMAL and does not contain an odd number of
digits.
- RPP / Use binary subscripts
- Use this rule to flag any data item that is used as a subscript
to access a table element, and that is not declared with a usage of
COMP, COMPUTATIONAL, or BINARY. Note that this rule does not flag
subscripts that are literals.
- The RPP / Program Structures category
includes rules that identify problems related to program structures:
- RPP / Avoid ACCEPT statements
- Use this rule to flag all ACCEPT statements.
- RPP / Avoid ACCEPT statements containing FROM CONSOLE or FROM
SYSIN
- Use this rule to flag ACCEPT statements that contain the phrase
FROM CONSOLE or FROM SYSIN.
- RPP / Avoid ALTER statements
- Use this rule to flag ALTER statements.
- RPP / Avoid CALL statements with a literal program name
- Use this rule to flag CALL statements that specify the program
name as a literal.
- RPP / Avoid CANCEL statements
- Use this rule to flag CANCEL statements.
- RPP / Avoid CORRESPONDING phrases
- Use this rule to flag ADD, SUBTRACT, and MOVE statements that
contain a CORRESPONDING phrase.
- RPP / Avoid DISPLAY statements containing UPON CONSOLE
- Use this rule to flag DISPLAY statements that contain UPON CONSOLE.
- RPP / Avoid ENTRY statements
- Use this rule to flag ENTRY statements.
- RPP / Avoid EXIT PROGRAM statements
- Use this rule to flag EXIT PROGRAM statements.
- RPP / Avoid GO TO statements
- Use this rule to flag all GO TO statements.
- RPP / Avoid GO TO statements, except those that reference an EXIT
paragraph
- Use this rule to flag all GO TO statements, except those that
transfer control to an exit paragraph. An exit paragraph is a paragraph
containing only an EXIT statement.
- RPP / Avoid IF without ELSE
- Use this rule to flag IF statements that do not contain an ELSE
clause.
- RPP / Avoid NEXT SENTENCE phrases
- Use this rule to flag all NEXT SENTENCE phrases.
- RPP / Avoid PERFORM, except PERFORM section
- Use this rule to flag all PERFORM statements, except those that
contain sections only.
- RPP / Avoid PERFORM statements
- Use this rule to flag PERFORM statements in Programs and Screens.
The rule does not apply to Macros.
- RPP / Avoid RESERVE clauses in FILE-CONTROL paragraphs
- Use this rule to flag RESERVE clauses in FILE-CONTROL paragraphs.
- RPP / Avoid SORT statements
- Use this rule to flag SORT statements in Programs and Screens.
The rule does not apply to Macros.
- RPP / Avoid STOP RUN and STOP literal statements
- Use this rule to flag STOP RUN and STOP statements.
- RPP / Avoid THRU phrases in PERFORM statements
- Use this rule to flag PERFORM statements that include a THRU phrase.
- RPP / Avoid using level-88 entries in data descriptions
- Use this rule to flag data descriptions that use level-88 entries.
Each level-88 entry is flagged.
- RPP / Avoid using more than one EXIT statement per section
- Use this rule to flag sections that contains more than one EXIT
statement.
- RPP / Avoid using SECTION in the PROCEDURE DIVISION
- Use this rule to flag any SECTION declarations in the PROCEDURE
DIVISION.
- RPP / Avoid XML PARSE statements
- Use this rule to flag XML-PARSE statements.
- RPP / EXEC CICS: Check EIBRESP after NOHANDLE
- Use this rule to flag any EXEC CICS statement that specifies the
NOHANDLE option and is not followed by an IF statement or an EVALUATE
statement that checks the values of EIBRESP. The statement following
the EXEC CICS statement is flagged if it is not one of the following:
an IF or EVALUATE statement that references EIBRESP, or a PERFORM
statement leading to a block of code whose first statement is an IF
or EVALUATE statement that references EIBRESP.
- RPP / 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 DFHRESP function call, in the following contexts: in any relation
condition, and in any WHEN unit of a SELECT statement in which the
data item is the selection subject.
- RPP / EXEC CICS: Use the RESP option
- Use this rule to flag CICS EXEC commands that do not include the
RESP option.
- RPP / EXEC SQL: Check the value of SQLCODE after an EXEC SQL statement
- Use this rule to flag any EXEC CICS statement that is not followed
by an IF statement or an EVALUATE statement that checks the value
of SQLCODE. The statement following the EXEC SQL statement is flagged
if it is not one of the following: an IF or EVALUATE statement that
references SQLCODE, or a PERFORM statement leading to a block of code
whose first statement is an IF or EVALUATE statement that references
SQLCODE.
- RPP / Use an EXIT paragraph in each section
- Use this rule to flag sections that do not contain an exit paragraph.
An exit paragraph is a paragraph containing only an EXIT statement.
- RPP / Use a WHEN OTHER phrase with an EVALUATE statement
- Use this rule to flag EVALUATE statements that do not include
a WHEN OTHER phrase.
- RPP / Use CONTINUE rather than NEXT SENTENCE inside a scoped range
- Use this rule to flag NEXT SENTENCE statements that lie within
the scope of any statement that has an explicit scope terminator.
- RPP / Use CURRENT-DATE rather than ACCEPT DATE or ACCEPT TIME
- Use this rule to flag ACCEPT DATE and ACCEPT TIME statements.
- RPP / Use level numbers in the sequence 01, 05, 10, 15...
- Use this rune to flag data structure definitions containing level
numbers that are not in an ascending sequence, or that do not have
a value of either 1 or a multiple of 5.
- RPP / Use SEARCH ALL rather than SEARCH to search a table
- Use this rule to flag tables searches that use SEARCH rather than
SEARCH ALL.
- RPP / Use THRU phrases in PERFORM statements
- Use this rule to flag PERFORM statements that do not include a
THRU phrase.