Rational Developer for System z provides an analysis engine
that developers can use to analyze their COBOL code early in the development
phase, to ensure that they are following their internal guidelines,
best practices, coding standards.
Rational Programming
Patterns for System z extends the Software Analyzer to provide analysis
support for design entities and specific code.
With the COBOL analysis provider, you can run analysis during COBOL
code development against a set of selected rules, view results (list
of items that break rules) and apply quick fix where appropriate.
Implementation
Before invoking the analysis
of the COBOL code, open the Software Analyzer Configurations dialog
to define a configuration rules set and specify:
- the scope (analyze 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).
You can then start the analysis on a selected file or
project by right-click, action Software Analyzer and
select the rule set previously defined. The 'Software
Analyzer Results' view displays the list of the non-respected
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 and select
the View Result action. The COBOL file opens
up in the editor and the line in violation is highlighted.
After
correcting the violations and saving, you can start again the analysis
to check that all 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
has been extended to provide analysis support for Rational Programming
Patterns for System z design entities.
There are two categories
of rules for this analysis:
- The All Entities category contains the
rules:
- A non blank label is mandatory on design entities
- At least one keyword is mandatory on design entities
- The Segment Entities category includes
the rules:
- A segment must use only defined data elements
- Avoid calling the same data element multiple times in a segment
Specific COBOL Code Review
The standard
rules in Software Analyzer Configurations have been completed with
Rational Programming Patterns for System z rules. These rules apply
only to specific code inserted by the user in a generated COBOL program.
To
differentiate them from the Rational Developer for System z standard
rules, 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 / Pattern Driven Programming category
includes the rules:
- RPP / Never override a generated line.
The rule checks
that no line of generated code, including code from a Macro, is overridden.
- RPP / Never override a line coming from a macrostructure.
The
rule checks that no line coming from a Macro is overridden.
- RPP / User code must be in a user function.
The rule
checks 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.
The
rule checks 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 / Naming Conventions category contains
the rule 'RPP / Use PROGRAM-ID that matches the source member
name'.
- The RPP / Performance category includes
the rules:
- RPP / Avoid INITIALIZE statement. Use elementary MOVE statements
or VALUE clauses
- RPP / Avoid OCCURS DEPENDING ON clauses
- RPP / Avoid subscripts in table access. Use indexes
- RPP / Use binary subscripts
- RPP / Use DFHRESP value to check response code
- RPP / Use EVALUATE statement rather than nested IF statement
- The RPP / Program Structures category
includes the rules:
- RPP / A GO TO statement can reference a paragraph only if it is
an exit paragraph
- RPP / Avoid ACCEPT FROM CONSOLE statements
- RPP / Avoid ACCEPT statements
- RPP / Avoid ALTER statements
- RPP / Avoid CALL statement with program-name. Use dynamic calls
- RPP / Avoid COPY SUPPRESS statements
- RPP / Avoid CORRESPONDING phrases
- RPP / Avoid ENTRY statements
- RPP / Avoid EXIT PROGRAM statements
- RPP / Avoid GO TO statements
- RPP / Avoid NEXT SENTENCE phrases
- RPP / Avoid RESERVE clause in FILE-CONTROL paragraphs
- RPP / Avoid STOP RUN and STOP literal statements
- RPP / Avoid the THRU phrase in PERFORM statements
- RPP / Use THRU phrase with PERFORM statement
- RPP / Use WHEN OTHER phrase with EVALUATE statement