FP on Cobol:S1728 (Alignment of data-item declarations) (AcuCobol)

We are scanning Cobol sources.

When we have a 01-level field with an 88-level condition, followed by a 78-level constant definition,
we get 2 code-smell warnings about ‘fields with the same level not being aligned’.
Moving the 78-level constant definition up in the source, so that it comes before the 01-level field makes the code-smells go away.
We believe that 66, 67, 78 and 88-level definitions should be exluded from this rule.

Versions used:
Cobol: AcuCobol version 10.2.1, fixed format
SonarQube: Enterprise Edition Version 9.6.1 (build 59531)

Source code example:

       IDENTIFICATION DIVISION.
       PROGRAM-ID. PP0041.
       WORKING-STORAGE SECTION.
       01 FIELD-1-LEVEL-01           PIC X(01).
          88 FIELD-1-CONDITION-NAME  VALUE "Y" FALSE "N".
       78 CONSTANT-78-LEVEL          VALUE "Constant".
       PROCEDURE DIVISION.
           IF FIELD-1-CONDITION-NAME
              DISPLAY CONSTANT-78-LEVEL
           END-IF
           GOBACK
           .

Hi Jos,

Sorry for the late reply.

You’re right, that’s a false positive that we should fix.

I guess you mean 66, 77, 78 and 88.
Out of those 4:

  • We don’t raise issues with levels 66 and 77.
  • I believe that it makes sense for the rule to raise an issue when several 88-level condition names are associated with the same variable and are not aligned.

In the end, I think that we have to change the behavior only for level 78.
Please tell me if I missed something.
I created SONARCOBOL-1675 to track this problem.

Thanks a lot for your feedback!

Pierre-Yves