Checking for Code Guidelines in COBOL Editor

This feature allows you to check for syntax errors in COBOL and is applicable only to COBOL editors. This functionality is disabled with all other editor types. You can perform this operation using one of the following methods:

The Code Guidelines are listed in the COBOL Code Guidelines view.

You can set your rules for the COBOL statements. To set the rules for error checks, do the following:

  1. Click Windows > Preferences.

  2. In the Preferences window, expand COBOL and click Code Guidelines check.

You can set the following rules in the Error Checks page:

By default, all rules are enabled with default priorities and the indent spaces for the indentation rule. You can also set the priority from the drop-down list against each rule. You can set only the rules you want to apply by checking the respective boxes.

The following descriptions of Error Checks are based on the default settings:

This rule lists all the duplicated section and paragraph names in the program.

This rule lists all instances of GO TO except when used in ON ERROR or AT END clause.

Example:

          E.
                 ADD STEPP TO CKKY.
                 IF CKKY > MAXK GO TO F.
                 GO TO RETRLOP.

          F.
                 EXIT.
              RETRLOP.
                 ADD STEPP TO CKY.

In the above example, GO TO RETRLOP. is listed in the COBOL Code Guidelines view because GO TO is used against this rule.

Lists the perform statements where the section or paragraph that is being performed is empty.

Example:

START.

IF RECORD-NUM OF AY = 0
OR PAGE-NUM OF EY   
PERFORM SNAPS.      
GO TO B.            

          SNAPS.              

B.
     MOVE  1 TO S.

In the above example, PERFORM SNAPS is listed in the COBOL Code Guidelines view because SNAPS is empty.    

All IF statements are checked for indentation issues.

If the line after the IF statement is not correctly indented, it is listed in the Error view.

All ELSE and END-IF statements must start from the preceding IF statement’s starting column.

All the lines which are other than IF, ELSE and END-IF statements must at least start with the indentation column starting with the preceding IF statement and the indentation spaces specified in the preference.

Example: The indentation space is set to 1.

1 if a=x
2  move a to y
3 else   if b = x
4           move b to y
5     else
6        move c to y
7     end-if
8 end-if.  

In the above example,

Line 2, move a to x must have started in the same column as a=x

Line 5, else is not matching with the preceding if column

Line 6, move c to y is not matching with b = x

Line 7 end-if is not matching with if column

Lines 2, 5, 6, and 7 are listed in the Code Guidelines view.

Lists all DMS command statements in the Procedure Division where ON ERROR clause is not specified. The following are the Database Keywords considered for this rule.

ACQUIRE

CLOSE

DELETE  

DEPART

FETCH

FIND

FREE  

GET

IMPART

INSERT

KEEP

LOG  

MODIFY

OPEN

REMOVE

STORE

The sections that have not been performed explicitly are listed within this rule.

The COBOL Code Guidelines view is updated with new data every time the user runs the COBOL Code Guidelines Check feature. You can expand, collapse, and remove all data for all nodes in the tree format view and save the contents to a text file. To save the Code Guidelines view, click .