Ccodemod

codemod/abap-complex-expression-mining

Annotate overly complex ABAP boolean expressions with metrics and remediation comments.

standardizationabapcomplexitycode-quality
Public
0 executions

Run locally

npx codemod @codemod/abap-complex-expression-mining

@codemod/abap-complex-expression-mining

Annotate overly complex ABAP boolean expressions with inline remediation comments, complexity metrics, and guidance to help teams reduce maintainability issues.

What It Rewrites

The codemod scans .abap and .asprog files for IF, ELSEIF, CHECK, WHILE, and ASSERT statements.

When a statement's complexity score is greater than the configured maximum, the codemod inserts three ABAP comment lines immediately above it:

  • A TODO line with the measured score and configured maximum
  • A metrics line with logical-operator count and maximum parenthesis depth
  • A remediation line suggesting extraction into helper variables or methods

Complexity score is calculated as:

text

Preserve Cases

  • Statements at or below the configured maximum are unchanged
  • Statements already preceded by this codemod's TODO annotation are left unchanged
  • Non-target ABAP statements are unchanged

Usage

bash

Example

Before:

abap

After:

abap

Development

bash

Ready to contribute?

Build your own codemod and share it with the community.