Ccodemod

codemod/abap-mergeable-nested-if-miner

Rewrite directly nested ABAP IF blocks into a single IF with a combined condition.

abaptransformationcontrol-flowmaintainability
Public
0 executions

Run locally

npx codemod @codemod/abap-mergeable-nested-if-miner

@codemod/abap-mergeable-nested-if-miner

Rewrite directly nested ABAP IF blocks into a single IF ... AND ... condition to simplify redundant control flow.

Installation

bash

Usage

This codemod targets ABAP source files such as *.abap and *.asprog and rewrites only the safe, mechanical case where an outer IF contains exactly one nested IF and neither block has ELSE or ELSEIF branches.

Before:

abap

After:

abap

Preserve and no-op behavior:

  • Leaves blocks unchanged when the outer body contains sibling statements, comments, or blank lines around the nested IF
  • Leaves blocks unchanged when either IF has ELSE or ELSEIF
  • Repeats the rewrite across longer chains of directly nested IF blocks
  • Wraps merged condition parts containing OR or EQUIV in parentheses before combining them with AND

Implementation note:

The bundled Codemod runtime in this package does not expose an ABAP parser, so the transform uses a raw-text rewrite over ABAP files while the workflow routes files through JSSG for execution.

Development

bash

License

MIT

Ready to contribute?

Build your own codemod and share it with the community.