Existing COBOL rule must consider "National" values

We use SonarQube server 9.5 (build56709):
This is about the Cobol rule “[Strings should only be moved to variables large enough to hold them without truncation].
The piece of code is:
MOVE N’X902’
TO RSPN-CD IN L40-P13915

The move done is a move as a national values, The N indicates the national move and ‘X902’ is the value of the move. The message that we see is: Increase the size of “RSPN-CD” (PIC N(04)) or do not “MOVE” N’X902’ (of size 5) to it.
As you can see, the length of X902 is 4 characters and fits in the result field RSPN-CD. RSPN-CD is declared as: RSPN-CD PIC N(04).

Could you update this rule so it can handle the national fields on z/OS?

Thanks in advance.
Henk van der Wijk

Indeed, there’s a problem in the way our COBOL analyzer understands national literals such as N'X902' and that generates false positives such as the one you encountered.
I created SONARCOBOL-1629 to track this problem.
We’ll see if we can fix it in the next release of our COBOL analyzer.

Thanks a lot for your feedback!
Pierre-Yves Nicolas

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.