We are scanning Cobol code, and we get undesirable hits on rule S1303 (Sections should not be empty).
The problem is that the sections that trigger the issue are performed from within a copymember.
We have copymembers that can be used in many different scenario’s, and it is thinkable that in some scenarios some sections don’t need implementation. So we then want to leave them empty.
(It is a bit like implementing an interface in Java, where all methods need to be implemented, but sometimes a method doesn’t need to do anyting. Then you make an empty implementation of the method.)
Below is an example program and a copymember, with one section used in this context, and the other one not needed in this context.
IDENTIFICATION DIVISION. PROGRAM-ID. PP0043. PROCEDURE DIVISION. MAIN SECTION. PERFORM SECTION-IN-COPYFILE GOBACK . CALLED-FROM-COPYFILE-1 SECTION. PERFORM DO-WORK-NEEDED-IN-THIS-CONTEXT . CALLED-FROM-COPYFILE-2 SECTION. * No work to be done in this context. . DO-WORK-NEEDED-IN-THIS-CONTEXT SECTION. DISPLAY "Doing something useful" . COPY "C/CODE/COPYPP0043".
In copyfile COPYPP0043:
SECTION-IN-COPYFILE SECTION. PERFORM CALLED-FROM-COPYFILE-1 PERFORM CALLED-FROM-COPYFILE-2 .
Cobol: Acucobol 10.2.1
SonarQube: * 10.2.1 (build 78527)
Please fix this problem by not triggering the issue when an empty section is performed from within a copymember.