Uploaded image for project: 'Rules Repository'
  1. Rules Repository
  2. RSPEC-3939

"OCCURS DEPENDING ON" should not be used

    XMLWordPrintable

    Details

    • Type: Code Smell Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Message:
      Replace this clause with a simple "OCCURS" clause with no "DEPENDING [ON]".
    • Default Severity:
      Major
    • Impact:
      Low
    • Likelihood:
      High
    • Covered Languages:
      Cobol
    • Irrelevant for Languages:
      ABAP, C#, C, C++, CSS, Flex, HTML, Java, JavaScript, Objective-C, PHP, PL/I, PL/SQL, Python, RPG, Swift, VB.Net, VB6, XML
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      5min
    • Analysis Scope:
      Main Sources, Test Sources

      Description

      OCCURS DEPENDING ON clauses are complicated to use correctly and do not provide any benefits with regard to memory consumption. It is best to avoid them.

      Noncompliant Code Example

      01  MYTABLEACCOUNT PIC S9(4) BINARY.
      01  MYTABLE.
        05  MYITEM OCCURS 1 to 1000 DEPENDING ON MYTABLEACCOUNT.
          10  MYFIELD1 PIC X(8).
          10  MYFIELD2 PIC S9(4) BINARY.
      

      Compliant Solution

      01  MYTABLE.
        05  MYITEM OCCURS 1000.
          10  MYFIELD1 X(8).
          10  MYFIELD2 PIC S9(4) BINARY.
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              jeanchristophe.collet Jean-Christophe Collet (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated: