The code contains too many long PIC declaration pattern

Why you should care

While describing a PICTURE, once the length of a sequence exceeds 3 characters, use the factorized notation. Edition pictures (presence of Z) are not concerned.

How we detect

CAST Highlight counts one occurrence each time in the WORKING SECTION a PICTURE description not containing “Z” exceed sequences of more than three characters. In the following patterns, where sequences do not contain parentheses:

  • PIC <sequence 1>
  • PIC S<sequence 1>
  • PIC <sequence 1>V<sequence 2>
  • PIC S<sequence 1>V<sequence 2>

The length of <sequence 1> and <sequence 2> (if any) should not exceed 3 characters, excluding s if present.

Bad Code

PIC 9999
PIC 9999V9
PIC s9999V9
PIC XXXX

Good Code

PIC 9(4)
PIC 9(4)V9 
PIC s9(4)V9
PIC X(4)
PIC s999
PIC 9(7)V99999999999

References

Coming soon…
5362

About CAST and Highlight’s Code Insights

Over the last 25 years, CAST has leveraged unique knowledge on software quality measurement by analyzing thousands of applications and billions of lines of code. Based on this experience and community standards on programming best practices, Highlight implements hundreds of code insights across 15+ technologies to calculate health factors of a software.