CodeAnt AI home pagelight logodark logo
  • Support
  • Dashboard
  • Dashboard
  • Join Community
Start Here
  • What is CodeAnt?
Setup
  • Github
  • Bitbucket
  • Gitlab
  • Azure Devops
Pull Request Review
  • Features
  • Customize Review
  • Quality Gates
  • Integrations
Scan center
  • Code Security
  • Code Quality
  • Cloud Security
  • Engineering Productivity
Integrations
  • Jira
  • Test Coverage
  • CI/CD
IDE
  • Setup
  • Review
  • Enhancements
Rule Reference
  • Compliance
  • Anti-Patterns
    • Pyspark
    • Python
    • Java
    • C / CPP
    • C #
    • JavaScript
    • Jcl
    • Kotlin
    • Kubernetes
    • Abap
    • Apex
    • Azure Source Manager
    • Php
    • Pli
    • Plsql
    • Secrets
    • Swift
    • Terraform
    • Text
    • Tsql
    • Rpg
    • Ruby
    • Scala
    • Vb6
    • Vbnet
    • Xml
    • Flex
    • Go
    • Html
    • Docker
    • Css
    • Cobol
    • Common
  • Code Governance
  • Infrastructure Security Database
  • Application Security Database
Resources
  • Open Source
  • Blogs
Anti-Patterns

Jcl

COND code should be should be set after a certain step

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.

Copy
//MYJOB JOB ,MSGLEVEL=1
//STEP1    EXEC PGM=FIRSTPGM
//STEP2    EXEC PGM=SECONDPGM
//STEP3    EXEC PGM=THIRDPGM

Jobs and procedures should not have too many steps

Having too many steps in a single job or procedure makes it harder to understand and maintain. It can also mean that it is aggregating too many responsibilities and should be split.

Copy
//MYJOB  JOB
//STEP01 EXEC PGM=DOTHING
//STEP02 EXEC PGM=DOTHING
//STEP03 EXEC PGM=DOTHING
//STEP04 EXEC PGM=DOTHING   <-- Noncompliant

Avoid the use of in-stream data in procedures

Earlier versions of z/OS and certain installations do not support in-stream data in procedures. This can lead to inconsistencies within the codebase and compatibility issues.

Copy
//MYPROC   PROC
//STEP1    EXEC PGM=DOTHING
//SYSIN    DD *
Input data
/*
//         PEND
//* Call procedure
//CALLPRC  EXEC PROC=MYPROC

Job names should comply with a naming convention

Shared naming conventions allow teams to collaborate efficiently. This rule checks that all job names match a provided regular expression.

Copy
//* Noncompliant
//$JOB01  JOB

Positional parameters must precede keyword parameters

JCL requires positional parameters to be specified before any keyword parameters. Having keyword parameters defined before a positional parameter will trigger a JCL error.

Copy
//MYJOB JOB CLASS=X,'TRIGGER'

Procedure names should comply with a naming convention

Shared naming conventions allow teams to collaborate efficiently.

This rule raises an issue when a procedure name does not match a provided regular expression.

For example, with the default provided regular expression ^[A-Z][A-Z0-9]*$, the procedure:

Copy
//* Noncompliant
//$PROC1 PROC

Track uses of forbidden data set names

This rule allows banning the usage of certain data set names.

Copy
//EXEC PGM=SORT
//SORTOUT DD DSN=AB.FOOBAR.XYZ

Missing mandatory statement name

In JCL, it is expected for a PROC statement inside of a job stream to have a name.

Copy
//MYJOB   JOB DXXX
//        PROC
//STEP1   EXEC PGM=MYPGM
//        PEND

Track uses of disallowed programs and procedures

This rule allows banning the use of some programs or procedures.

Copy
//EXEC PGM=SORT
//EXEC PROC=SORT
//EXEC SORT

DD DATA statements should be delimited

The DD DATA statement continues reading in-stream data until it reaches the end delimiter (/* or the delimiter specified by the DLM parameter) or until it hits the end-of-file. This can lead to other JCL statements being mistakenly included in the data stream.

Copy
//STEP1 EXEC PGM=DOTHING
//SYSIN DD DATA
//ALPHA JOB ,MSGLEVEL=(1,1)
//NOPE  EXEC PGM=IEFBR14
//STEP2 EXEC PGM=IEFBR14
//* End of file

Track uses of forbidden statement parameters

This rule allows banning usage of certain statement parameters.

Copy
//OUTPUT1 INCLUDE MEMBER=FOOBAR

Do not use implicit SYSIN DD * statements

This behavior is implicit and may lead to confusion or unexpected behavior.

For example, this code:

Copy
//MYDD DD DSN=TEST
Some in-stream data
// DD DSN=CONCAT-DD

Names should not be too long

If a statement name exceeds the maximum size, it will trigger an error and prevent the program from being executed.

Copy
//MYEXPORTLAB     EXPORT SYMLIST=(TEST)
//MYEXECPROG.PROG EXEC PGM=ABC
//EXEC.MYPROGRAM  EXEC PGM=ABC

Procedures should not be empty

An empty {operationName} is generally considered bad practice and can lead to confusion, readability, and maintenance issues. Empty {operationName}s bring no functionality and are misleading to others as they might think the {operationName} implementation fulfills a specific and identified requirement.

There are several reasons for a {operationName} not to have a body:

  • It is an unintentional omission, and should be fixed to prevent an unexpected behavior in production.

  • It is not yet, or never will be, supported. In this case an exception should be thrown.

  • The method is an intentionally-blank override. In this case a nested comment should explain the reason for the blank override.

Copy
//MYPROC PROC
//       PEND

Unused function parameters should be removed

A typical code smell known as unused function parameters refers to parameters declared in a function but not used anywhere within the function’s body. While this might seem harmless at first glance, it can lead to confusion and potential errors in your code. Disregarding the values passed to such parameters, the function’s behavior will be the same, but the programmer’s intention won’t be clearly expressed anymore. Therefore, removing function parameters that are not being utilized is considered best practice.

Copy
//MYPROC PROC NAME1=SYS1,NAME2=SYS2,NAME3=SYS3 <--- Noncompliant
//STEP1 EXEC PGM=DOTHING
//THEFILE   DD DSN=&N1..INFILE,DISP=SHR
//          DD DSN=&N2..INFILE,DISP=SHR
// PEND
UnicornKotlin
twitterlinkedin
Powered by Mintlify
Assistant
Responses are generated using AI and may contain mistakes.