rspec/rules/S1880/rpg/rule.adoc
2022-02-04 16:28:24 +00:00

57 lines
1013 B
Plaintext

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)
include::message.adoc[]
endif::env-github,rspecator-view[]