We are scanning AcuCobol sources.
We see an error in the reporting of unused files:
The error occurs under the following conditions:
- The ‘SELECT’ of a file is in a separate copymember AND
- this copymember is added into a program AND
- The file is NOT used in the program.
When these conditions are met, the file is reported as being unused.
In itself that is correct, however the issue is reported on the copy-member, not on the source in which the copy-member was added.
If we create a copy-member with a SELECT, and we don’t insert it in any program, we get no issue reported on it.
A small reproducer program:
IDENTIFICATION DIVISION.
PROGRAM-ID. PP0047.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
COPY "C/SEL/PP0047".
DATA DIVISION.
FILE SECTION.
COPY "C/FD/PP0047".
WORKING-STORAGE SECTION.
01 FILE-STATUS PIC X(02).
PROCEDURE DIVISION.
MAIN SECTION.
GOBACK
.
The copy-member that contains the SELECT:
SELECT PP0047-FILE ASSIGN TO RANDOM PP0047-FILE-NAME
ORGANIZATION IS INDEXED
ACCESS MODE IS DYNAMIC
RECORD KEY IS PP0047-ID IN PP0047-REC
FILE STATUS IS FILE-STATUS.
And the copy-member that contains the FD:
FD PP0047-FILE.
01 PP0047-REC.
03 PP0047-ID PIC 9(10).
03 PP0047-DATA PIC X(90).
Versions used:
Cobol: Acucobol 10.2.1
SonarQube: * 10.4 (build 87286)
SonarScanner 5.0.1.3006
Please fix this error in the reporting.