Registry
Ccodemod avatar

codemod/abap-no-commented-out-code

Remove full-line ABAP comments that contain commented-out source statements from .abap files.

codemod0 executions

  • transformation
  • abap
  • comments
  • cleanup
Connect a repo
npx codemod @codemod/abap-no-commented-out-code

@codemod/abap-no-commented-out-code

Remove full-line ABAP comments that look like commented-out source statements from *.abap files.

What It Rewrites

  • Full-line * comments whose bodies look like ABAP statements such as assignments, control-flow lines, declarations, and method or PERFORM calls
  • Full-line " comments with the same code-like patterns
  • Contiguous comment-only blocks when every non-separator comment line in the block looks like ABAP code
  • Empty or separator comment lines inside a removable commented-out code block

Preserved Cases

  • Prose comments such as release notes or explanations
  • Trailing inline comments on active ABAP statements
  • Mixed comment blocks that contain both prose and code-like lines
  • Non-ABAP files

Heuristics

The codemod is intentionally conservative. It only removes comment blocks when every meaningful line in the block matches one of these code-like shapes:

  • Standalone block terminators such as ENDIF. or ENDLOOP.
  • Assignments such as lv_total = lines( lt_items ).
  • Method-style calls such as lo_service->run( ).
  • Control statements such as IF sy-subrc = 0.
  • Common ABAP statements such as CLEAR lv_total. or SELECT ... .

If a comment block mixes prose with code-like lines, the whole block stays unchanged.

Usage

bash
# Run from the registry
codemod run @codemod/abap-no-commented-out-code

# Run the local workflow
codemod run -w workflow.yaml

# Preview local changes without writing files
node --import tsx scripts/codemod.ts --dry-run .

Development

bash
pnpm test
pnpm run check-types
pnpm run validate
node --import tsx scripts/codemod.ts --dry-run .

License

MIT

Ready to evolve your codebase?

Build tailored, compiler-aware skills to assess, plan, and automate complex codebase changes.