rspec/rules/S2327/rpg/rule.adoc

55 lines
1.1 KiB
Plaintext
Raw Permalink Normal View History

== Why is this an issue?
2021-01-27 13:42:22 +01:00
When multiple, adjacent ``++MONITOR++`` statements have duplicate ``++ON-ERROR++`` blocks, they should be merged to consolidate the ``++ON-ERROR++`` logic for cleaner, more readable code. Note that this applies even when there is intervening code outside any ``++MONITOR++`` block.
2020-06-30 12:48:07 +02:00
=== Noncompliant code example
2020-06-30 12:48:07 +02:00
2022-02-04 17:28:24 +01:00
[source,rpg]
2020-06-30 12:48:07 +02:00
----
/free
monitor;
// do something...
on-error;
CALLP HandleError(*param);
endmon;
// do un-monitored thing
monitor;
// do something else...
on-error; // Noncompliant
CALLP HandleError(*param);
endmon;
/end-free
----
=== Compliant solution
2020-06-30 12:48:07 +02:00
2022-02-04 17:28:24 +01:00
[source,rpg]
2020-06-30 12:48:07 +02:00
----
/free
monitor;
// do something...
// do un-monitored thing
// do something else...
on-error;
CALLP HandleError(*param);
endmon;
----
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[]