rspec/rules/S1630/rpg/rule.adoc

82 lines
1.7 KiB
Plaintext
Raw Normal View History

== Why is this an issue?
2021-04-28 16:49:39 +02:00
If a file is defined without the ``++USROPN++`` statement then the natural RPG logic will deal with opening and closing it. However, files defined with ``++USROPN++``, must be both explicitly ``++OPEN++``ed and ``++CLOSE++``d.
=== Noncompliant code example
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,rpg]
2021-04-28 16:49:39 +02:00
----
FEWPCCR1 O E PRINTER USROPN
F INFDS(WSFD01)
F INFSR(*PSSR)
C OPEN EWPCCR1
C CLOSE *ALL
----
2022-02-04 17:28:24 +01:00
[source,rpg]
2021-04-28 16:49:39 +02:00
----
FEWPCCR1 O E PRINTER USROPN
F INFDS(WSFD01)
F INFSR(*PSSR)
/free
open EWPCCR1;
close *ALL;
/end-free
----
=== Compliant solution
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,rpg]
2021-04-28 16:49:39 +02:00
----
FEWPCCR1 O E PRINTER USROPN
F INFDS(WSFD01)
F INFSR(*PSSR)
C OPEN EWPCCR1
C CLOSE EWPCCR1
----
2022-02-04 17:28:24 +01:00
[source,rpg]
2021-04-28 16:49:39 +02:00
----
FEWPCCR1 O E PRINTER USROPN
F INFDS(WSFD01)
F INFSR(*PSSR)
/free
open EWPCCR1;
close EWPCCR1;
/end-free
----
== Resources
2021-04-28 16:49:39 +02:00
* CWE - https://cwe.mitre.org/data/definitions/459[CWE-459 - Incomplete Cleanup]
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Explicitly close this file.
'''
== Comments And Links
(visible only on this page)
=== relates to: S1725
endif::env-github,rspecator-view[]