Rule Definition
Since the Cobol 85 standard, Cobol language has allowed using statement terminators. Thus, the IF statement can be ended by a dot or by its specific scope terminator (END-IF). In the case where END-IF is not used, then the first dot encountered ends the IF block. This can create problems because a dot is very difficult to see into the code of a program and it is very easy for a developer who wants to insert a new statement into the IF scope to add a dot accidentally. For instance, the following code contains a dot added accidentally before the GO TO statement (it belongs to the IF-block):
IF CPT = 10
MOVE 100 TO CD-VAR1.
GO TO PARA-10.
COMPUTE WS-TOT = WS-MAX - WS-MIN.
As a result, the GO TO statement will be executed systematically and the next COMPUTE will become dead code!
This kind of troubles may produce unpredictable results and the application can become instable. In addition, even if the developer must only remove a dot, then it is extremely difficult for him to find where the problem is.
Remediation
Add END-IF terminator to all IF statements.
Violation Code Sample
* In this example, the IF block ends after the PERFORM statement
* because a dot has been inserted accidentally
IF A = 10
MOVE "OK" TO VAR1
PERFORM PARA-1.
MOVE 19 TO VAR2.
ADD 1 TO A.
Fixed Code Sample
IF A = 10
MOVE "OK" TO VAR1
PERFORM PARA-1
MOVE 19 TO VAR2
END-IF
ADD 1 TO A.
Reference
IBM Enterprise Cobol for z/OS - Language Reference
Related Technologies
Cobol
Technical Criterion
Complexity - Algorithmic and Control Structure Complexity
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.