Incorrect Code Smell about SELECT being in a copymember (AcuCobol)

We are trying to analyse Cobol sources.

When there is a copymember with the content of a SELECT statement in a source, the analyzer generates a code-smell warning saying that the SELECT should be taken out of the copymember.
Although we generally consider it good practice to not put structural program elements in a copymember,
we think this warning is wrong:
A SELECT is NOT a structural part of the program.
There may be more than one of them in one program, and the same SELECT can appear in many different programs.
Below there is a sample program that shows how we have set up our file I/O, with a bunch of copymembers for each file.
Having a warning for every use of a SELECT copymember does not fit into that strategy.

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

Source code:

       IDENTIFICATION DIVISION.
       PROGRAM-ID. PP0039.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
          COPY "C/SEL/ORDER".
       DATA DIVISION.
       FILE SECTION.
          COPY "C/FD/ORDER".
       WORKING-STORAGE SECTION.
       01 FILE-STATUS            PIC X(02).
       PROCEDURE DIVISION.
       MAIN SECTION.
           GOBACK
           .

SELECT copymember (“C/SEL/ORDER”):

       SELECT ORDER-FILE ASSIGN TO RANDOM ORDER-FILE-NAME
              ORGANIZATION IS INDEXED
              ACCESS MODE IS DYNAMIC
              RECORD KEY IS ORDER-ID IN ORDER-REC
              FILE STATUS IS FILE-STATUS.

REC copymember (“C/REC/ORDER”):

       01  ORDER-REC.
           03  ORDER-KEY.
               05 ORDER-ID                      PIC 9(10).
           03  ORDER-DATA.
               05  ORDER-FIELD-ONE              PIC X(05).
               05  ORDER-FIELD-TWO              PIC X(05).

FD copymember (“C/FD/ORDER” ):

       FD ORDER-FILE.
       COPY "C/REC/ORDER".

The generated code smell:

What you ask seems fair.
I created SONARCOBOL-1674 to change the behavior of the rule.
Thanks for your feedback.

Hi Pierre-Yves Nicolas,

After submitting the above issue I saw that the same applies to ‘FD’ statements.
Maybe you would want to amend the issue,so that the exception applies to 'FD" statments as well.

With kind regards,

Jos Abrahams

Hi,

Indeed, it can raise issues on FD even if it’s not really intentional: it happens when omitting DATA DIVISION and FILE SECTION.
I updated the description of the ticket accordingly.

Thank you!
Pierre-Yves

Hi Pierre-Yves,

This clarifies why had not seen this much earlier.
I already wondered why that was, as every program that has a select has an FD as well.
But your elaboration explains why an issue is not always raised on an FD being in a copymember.
Thank you!

With kind regards,
Jos Abrahams