Rule Definition
When using PERFORM ... THROUGH, someone may add a new paragraph between existing paragraphs within the bounds of the statement. It results in unexpected behaviors difficult to debug.
Remediation
Create a section containing the paragraphs performed by PERFORM THROUGH and replace the calling statements by PERFORM to section.
Violation Code Sample
PROCEDURE DIVISION.
A.
PERFORM PAR-BEG THROUGH PAR-END.
STOP RUN.
PAR-BEG.
IF VAR1 = 99
MOVE 0 TO VAR1
END-IF
PAR-PROC.
MOVE 50 TO VAR2.
PAR-END.
EXIT.
Fixed Code Sample
PROCEDURE DIVISION.
A.
PERFORM PAR.
STOP RUN.
PAR SECTION.
PAR-BEG.
IF VAR1 = 99
MOVE 0 TO VAR1
END-IF
PAR-PROC.
MOVE 50 TO VAR2.
PAR-END.
EXIT.
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.