rspec/rules/S4882/cobol/rule.adoc
Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

45 lines
1.1 KiB
Plaintext

== Why is this an issue?
Some COBOL compilers such as IBM one will assume that the minimum value of ``++OCCURS DEPENDING ON++`` is 1 but nothing is enforcing that and this behaviour can change or be different when using another compiler.
Setting the minimum value of ``++OCCURS DEPENDING ON++`` makes the code more readable, and less dependent on compiler.
=== Noncompliant code example
[source,cobol]
----
01 MY-TABLE-COUNT PIC S9(4) BINARY.
01 MY-TABLE.
03 MY-ITEM OCCURS 500 TIMES *> Noncompliant
DEPENDING ON MY-TABLE-COUNT.
05 MY-FIELD-01 PIC X(08).
05 MY-FIELD-02 PIC 9(05).
----
=== Compliant solution
[source,cobol]
----
01 MY-TABLE-COUNT PIC S9(4) BINARY.
01 MY-TABLE.
03 MY-ITEM OCCURS 1 TO 500 TIMES *> Compliant; minimum value is 1
DEPENDING ON MY-TABLE-COUNT.
05 MY-FIELD-01 PIC X(08).
05 MY-FIELD-02 PIC 9(05).
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Add a minimum value to this "OCCURS DEPENDING [ON]" clause.
endif::env-github,rspecator-view[]