We are scanning AcuCobol sources.
We see an error in the reporting of rule cobol:S1764:
Identical expressions should not be used on both sides of a binary operator.
The error occurs under the following conditions:
- The code that causes the issue is in a separate copymember AND
- the expressions in this code are not the same, BUT
- this copymember is added into a program with ‘COPY REPLACING’ AND
- after the REPLACING the expressions are the same
When these conditions are met a cobol:S1764 issue is reported.
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.
Although a construction like this is questionable, we do find it in (old) code, and we would like to see it reported correctly, so that the source in which the problem actually occurs is reported, and not the copymember (where no problem can be seen).
A small reproducer program:
IDENTIFICATION DIVISION.
PROGRAM-ID. PP0048.
WORKING-STORAGE SECTION.
PROCEDURE DIVISION.
COPY "C/CODE/PP0048CODE".
COPY "C/CODE/PP0048CODE" REPLACING "StRiNg" BY "STRING".
GOBACK
.
The copy-member that contains the expressions (C/CODE/PP0048CODE):
IF "StRiNg" EQUAL "STRING"
DISPLAY "Strings are equal"
ELSE
DISPLAY "Strings are different"
END-IF
Versions used:
Cobol: Acucobol 10.2.1
SonarQube: * 10.4 (build 87286)
SonarScanner 5.0.1.3006
Please fix this error in the reporting.