codemod/abap-method-name-convention-miner
Rewrite ABAP method identifiers to lower snake case across declarations, implementations, and common call sites.
# @codemod/abap-method-name-convention-miner
Rewrite ABAP method identifiers to lower snake case across declarations, implementations, and common call sites.
## Installation
```bash
# Install from registry
codemod run @codemod/abap-method-name-convention-miner
# Or run locally
codemod run -w workflow.yaml
```
## Usage
This codemod targets ABAP source files matching `**/*.abap` and rewrites method names like:
```abap
CLASS lcl_invoice DEFINITION.
PUBLIC SECTION.
METHODS calculateTotal IMPORTING iv_amount TYPE i.
ENDCLASS.
CLASS lcl_invoice IMPLEMENTATION.
METHOD calculateTotal.
result = me->calculateTotal( iv_amount ).
ENDMETHOD.
ENDCLASS.
```
into:
```abap
CLASS lcl_invoice DEFINITION.
PUBLIC SECTION.
METHODS calculate_total IMPORTING iv_amount TYPE i.
ENDCLASS.
CLASS lcl_invoice IMPLEMENTATION.
METHOD calculate_total.
result = me->calculate_total( iv_amount ).
ENDMETHOD.
ENDCLASS.
```
Preserve behavior:
- Rewrites `METHODS`, `CLASS-METHODS`, and `METHOD` declarations.
- Rewrites direct calls like `fooBar( )`, selector calls like `me->fooBar( )` and `cl_type=>fooBar( )`, and `CALL METHOD fooBar`.
- Leaves comments, string literals, and already snake_case method names unchanged.
- Skips renames that would collide with an already-present snake_case method name.
Implementation note:
- ABAP is not a parser-backed JSSG language here, so the transform uses a source-text rewrite scoped to method declarations and common invocation forms.
## Development
```bash
# Test the transformation
pnpm test
# Typecheck the codemod
pnpm run check-types
# Validate the workflow
pnpm dlx codemod@latest workflow validate -w workflow.yaml
# Publish to registry
pnpm dlx codemod@latest login
pnpm dlx codemod@latest publish
```
## License
MIT