Wrong file reported when issue is found on cobol:S1764

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.

Hi!

Thank you for reporting this issue and providing a source code sample for reproduction.
I can confirm the problem and I created a ticket to track it: [SONARCOBOL-1699] - Jira

Hi Anton,

Today I noticed that on this issue both the source and the copymember are reported as the cause of the issue:

This result is the best that can be expected I guess.

Last week we installed version 10.4.1; is it possible that this was fixed between 10.4 and 10.4.1?
The only other explanation I can think of is that we both missed the fact that the issue is reported on the main source as well.

As far as I am concerned SONARCOBOL-1699 can be closed.

With kind regards,

Jos Abrahams

Hi Jos,

thank you for the follow-up post.

Last week we installed version 10.4.1; is it possible that this was fixed between 10.4 and 10.4.1?
The only other explanation I can think of is that we both missed the fact that the issue is reported on the main source as well.

No, this is probably not related to the version upgrade, I too missed the additional reporting in SonarQube.
It is good that the issue is reported on both files, though with the current reporting, it is a bit hard to see the connection between the two reported instances.

I’ll update the ticket to reflect that it would be good to display a clear “issue flow”.

Best regards,

Anton

1 Like