2023-05-03 11:06:20 +02:00
== Why is this an issue?
2021-04-28 16:49:39 +02:00
This rule is a more precise version of S1308 preventing the use of ``++GO TO++``. The flow of a program is already complicated to understand with simple ``++GO TO++``s. It's even worse when a ``++GO TO++`` is executed conditionally like this is the case with ``++GO TO DEPENDING ON++``.
2021-04-28 18:08:03 +02:00
2023-05-03 11:06:20 +02:00
=== Noncompliant code example
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,cobol]
2021-04-28 16:49:39 +02:00
----
PROCEDURE DIVISION.
...
GO TO PARAGRAPH-10
PARAGRAPH-20
PARAGRAPH-30
DEPENDING ON WS-PARA-NUMBER *> Noncompliant
...
----
2021-04-28 18:08:03 +02:00
2023-05-03 11:06:20 +02:00
=== Compliant solution
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,cobol]
2021-04-28 16:49:39 +02:00
----
PROCEDURE DIVISION.
...
EVALUATE WS-PARA-NUMBER
WHEN 1
PERFORM PARAGRAPH-10
WHEN 2
PERFORM PARAGRAPH-20
WHEN 3
PERFORM PARAGRAPH-30
WHEN OTHER
PERFORM PARAGRAPH-99
END-EVALUATE
...
----
2021-04-28 18:08:03 +02:00
2021-06-02 20:44:38 +02:00
2021-06-03 09:05:38 +02:00
ifdef::env-github,rspecator-view[]
2021-09-20 15:38:42 +02:00
'''
== Implementation Specification
(visible only on this page)
2023-05-25 14:18:12 +02:00
=== Message
Refactor this code to remove the GO TO DEPENDING ON statement.
2021-09-20 15:38:42 +02:00
2021-06-08 15:52:13 +02:00
'''
2021-06-02 20:44:38 +02:00
== Comments And Links
(visible only on this page)
2023-05-25 14:18:12 +02:00
=== relates to: S1308
2021-06-03 09:05:38 +02:00
endif::env-github,rspecator-view[]