rspec/rules/S6945/jcl/rule.adoc
github-actions[bot] 6521c2385f
Create rule S6945: COND code should be used from certain step (#3744)
---------

Co-authored-by: sallaigy <sallaigy@users.noreply.github.com>
Co-authored-by: Gyula Sallai <gyula.sallai@sonarsource.com>
2024-03-26 16:01:21 +01:00

64 lines
1.4 KiB
Plaintext

== Why is this an issue?
In JCL, the `COND` code is used to control the execution of job steps based on the completion codes of previous steps.
Omitting the `COND` code in a subsequent step will lead to the execution of the step even when previous steps have failed.
This can result in unnecessary resource usage, potential data corruption, and can make debugging more difficult.
=== Exceptions
The rule will not trigger on job steps inside `IF/THEN/ELSE/ENDIF` statements.
== How to fix it
Code a `COND` parameter on this step and all subsequent steps.
=== Code examples
==== Noncompliant code example
With the rule parameter `steps` set to 2:
[source,jcl,diff-id=1,diff-type=noncompliant]
----
//MYJOB JOB ,MSGLEVEL=1
//STEP1 EXEC PGM=FIRSTPGM
//STEP2 EXEC PGM=SECONDPGM
//STEP3 EXEC PGM=THIRDPGM
----
==== Compliant solution
[source,jcl,diff-id=1,diff-type=compliant]
----
//MYJOB JOB ,MSGLEVEL=1
//STEP1 EXEC PGM=FIRSTPGM
//STEP2 EXEC PGM=SECONDPGM
//STEP3 EXEC PGM=THIRDPGM,COND=(4,LT)
----
== Resources
=== Documentation
* https://www.ibm.com/docs/en/zos/3.1.0?topic=statement-cond-parameter[z/OS MVS JCL Reference - EXEC statement - COND parameter]
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Parameters
.steps
****
----
^4$
----
Maximum number of steps without COND.
****
'''
endif::env-github,rspecator-view[]