rspec/rules/S1880/rpg/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

62 lines
1.0 KiB
Plaintext

== Why is this an issue?
The format used to write a record to a file should be cleared before each use. Otherwise stale data left in the format from previous records may be saved into the current record if it does not have data for all the fields in the format.
=== Noncompliant code example
[source,rpg]
----
C IF X <> Y
...
C ENDIF
C WRITE RECFMT
----
[source,rpg]
----
/free
if x <> y;
...
endif;
write recfmt;
/end-free
----
=== Compliant solution
[source,rpg]
----
C CLEAR RECFMT
C IF X <> Y
...
C ENDIF
C WRITE RECFMT
----
[source,rpg]
----
/free
clear recfmt;
if x <> y;
...
endif;
write recfmt;
/end-free
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Clear "XXX" before using it.
endif::env-github,rspecator-view[]