41 lines
862 B
Plaintext
41 lines
862 B
Plaintext
Even though closing an open file isn't always mandatory (for instance when stopping the execution of a COBOL program with the ``++STOP RUN++`` statement), it's good coding practice to always explicitly close any open files. This rule checks that for every ``++OPEN++`` statement there is a corresponding ``++CLOSE++`` statement somewhere in the program.
|
|
|
|
|
|
== Noncompliant Code Example
|
|
|
|
[source,cobol]
|
|
----
|
|
OPEN INPUT my-file
|
|
----
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
[source,cobol]
|
|
----
|
|
OPEN INPUT my-file
|
|
...
|
|
CLOSE my-file
|
|
----
|
|
|
|
|
|
== See
|
|
|
|
* https://cwe.mitre.org/data/definitions/459[MITRE, CWE-459] - Incomplete Cleanup
|
|
|
|
|
|
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[]
|