rspec/rules/S131/cobol/rule.adoc
Fred Tingaud 51369b610e
Make sure that includes are always surrounded by empty lines (#2270)
When an include is not surrounded by empty lines, its content is inlined
on the same line as the adjacent content. That can lead to broken tags
and other display issues.
This PR fixes all such includes and introduces a validation step that
forbids introducing the same problem again.
2023-06-22 10:38:01 +02:00

58 lines
1.7 KiB
Plaintext

== Why is this an issue?
The ``++EVALUATE++`` statement allows implementing case structures in Cobol. Each case is managed by a ``++WHEN++`` phrase activated by specific test of a variable.The ``++WHEN OTHER++`` phrase allows managing all the cases which have not been taken into account by the previous ``++WHEN++`` phrases. If the variable to be tested contains a new value that is not currently managed then the absence of the ``++WHEN OTHER++`` phrase will lead a situation in which no process will be performed for this value and the program may have uncontrolled or undefined behavior.
=== Noncompliant code example
[source,cobol]
----
A010-PRINCIPAL.
EVALUATE Y5FTAR-PER-ECN-CTS
WHEN '01'
MOVE 'A' TO WS-CD-PER-CTS
WHEN '02'
MOVE 'S' TO WS-CD-PER-CTS
WHEN '04'
MOVE 'T' TO WS-CD-PER-CTS
WHEN '12'
MOVE 'M' TO WS-CD-PER-CTS
END-EVALUATE.
----
=== Compliant solution
[source,cobol]
----
A010-PRINCIPAL.
EVALUATE Y5FTAR-PER-ECN-CTS
WHEN '01'
MOVE 'A' TO WS-CD-PER-CTS
WHEN '02'
MOVE 'S' TO WS-CD-PER-CTS
WHEN '04'
MOVE 'T' TO WS-CD-PER-CTS
WHEN '12'
MOVE 'M' TO WS-CD-PER-CTS
WHEN OTHERS
MOVE 'O' TO WS-CD-PER-CTS
END-EVALUATE.
----
include::../see.adoc[]
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]