rspec/rules/S1630/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

82 lines
1.7 KiB
Plaintext

== Why is this an issue?
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
[source,rpg]
----
FEWPCCR1 O E PRINTER USROPN
F INFDS(WSFD01)
F INFSR(*PSSR)
C OPEN EWPCCR1
C CLOSE *ALL
----
[source,rpg]
----
FEWPCCR1 O E PRINTER USROPN
F INFDS(WSFD01)
F INFSR(*PSSR)
/free
open EWPCCR1;
close *ALL;
/end-free
----
=== Compliant solution
[source,rpg]
----
FEWPCCR1 O E PRINTER USROPN
F INFDS(WSFD01)
F INFSR(*PSSR)
C OPEN EWPCCR1
C CLOSE EWPCCR1
----
[source,rpg]
----
FEWPCCR1 O E PRINTER USROPN
F INFDS(WSFD01)
F INFSR(*PSSR)
/free
open EWPCCR1;
close EWPCCR1;
/end-free
----
== Resources
* https://cwe.mitre.org/data/definitions/459[MITRE, 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[]