Quality Control Rules

Rational® Programming Patterns provides rules in Software Analyzer to perform the most common controls on the design files and the generated COBOL files.

Implementation

Before you start an analysis, you must open the Software Analyzer Configurations wizard to define a configuration rule set. To do so, right-click a file or a project and select Software Analyzer > Software Analyzer Configurations. The wizard Create, manage and run configurations opens. To create a configuration, right-click the line Software Analyzer in the list of configurations and give it a name in the Name field. Specify the following information:
  • In the Scope tab, indicate whether the analysis applies to the entire workspace, a working set, or one or more selected projects.
    Figure 1. Rational Software Analyzer - Scope tab
    Rational Software Analyzer - Scope tab

  • In the Rules tab, select the rules for the analysis. For each selected rule, you can specify the severity level (recommendation, warning, or severe).
    Figure 2. Rational Software Analyzer - Rules tab
    Rational Software Analyzer - Rules tab
To start the analysis, right-click a file or a project. Select Software Analyzer and the rule set that was 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 generated file opens in the editor where the violation was detected and the line in violation is highlighted.
Figure 3. Software Analyzer results
Software Analyzer results

Correct the violations and save. Then, you can start the analysis again to check that all the rules are respected.

Design Entities Analysis

The Rational Programming Patterns rules that analyze the design entities are gathered under Design Entities Analysis for RPP MAF.
  • 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

Some rules apply only to the specific code that is inserted by the user in a generated COBOL file.
The Rational Programming Patterns rules are gathered under COBOL Code Review RPP. They are all prefixed by RPP /.

The Naming Conventions, Performance, and Program Structures rules are equivalent to the rules of Rational Developer for System z® (IBM® Developer for z Systems™), but they restrict the control to specific code portions. However, the Pattern Driven Programming and Syntax Error rules are specific and have no equivalent in Rational Developer for System z (IBM Developer for z Systems).

  • The RPP / Naming Conventions category contains a rule that identifies problems that are 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 from its source file name. The file extension, if any, of the source file is run from the comparison.

  • The RPP / Pattern Driven Programming category includes rules that identify problems that are 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 have COBOL desynchronized with its models in a local workspace
    Use this rule to ensure that the COBOL files are synchronized with all the design files that were involved in their local generation.
    RPP / Never modify a line in IDENTIFICATION or ENVIRONMENT DIVISION
    Use this rule to ensure that no line of specific code is present in the IDENTIFICATION or ENVIRONMENT DIVISION of a 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 no automatic access subfunction in F80 is overridden 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 that comes 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 for problems that are 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. 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. If the nesting is more than one level deep, then the rule 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. This rule does not flag subscripts that are literals.

  • The RPP / Program Structures category includes rules for problems that are 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 if they transfer control to an exit paragraph. An exit paragraph is a paragraph that contains 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 if they 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 that follows 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 that leads 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 that follows 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 that leads 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 that contains 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 rule to flag data structure definitions that contain 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 table 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.
  • The RPP / Syntax Error category contains rules for problems that are related to syntax errors in the generated COBOL files:

    RPP / The COBOL must be analyzable by the COBOL syntax analyzer
    Use this rule to flag any COBOL file whose code cannot be analyzed by the parser because of syntax errors. By default, this rule raises a severe error.
    RPP / The COBOL must not have syntax errors
    Use this rule to flag any COBOL file whose code contains syntax errors. By default, this rule raises a warning only.


Feedback